Chapter 4 Optimization

Example: subroutine call converted to a relative branch

This section gives an example of a CALLS LABEL instruction with a target address within the range of a relative jump--that is, between -32,768 and +32,767 from the current program counter.

The source list is as follows.

 

opt

on

_TEXT

section

CODE, PUBLIC,1

sub_func

 

 

addr_set

calls

func_end

 

org

addr_set+128

func_end

rts

 

 

end

 

The final list file after assembly is shown next. Since the CALLS LABEL instruction in line four con- tains a target address that may be expressed with a 2-byte relative branch, the assembler replaces it with the CALLS LABEL variant with a 2-byte address field. Note that the mnemonics and object code are different.

 

 

 

opt4.lst Page 1

 

Loc

*** PanaX series Series MN1030 Cross Assembler ***

Object

Line

Source

opt

on

 

 

1

_TEXT

40000000

 

2

section

CODE, PUBLIC, 1

FAFF8000

3

sub_func

Calls

func_end

40000000

@4

addr_set

 

 

5

 

org

addr_set+128

40000080

 

6

func_end

F0FC

7

rts

 

40000080

8

 

 

 

 

9

 

end

 

*** Symbol

Table

***

opt4.lst Page 2

 

 

 

 

 

40000000

T

sub_func

 

 

 

40000000

T

addr_set

 

 

 

40000080

T

func_end

 

 

58 Usage Example

Page 70
Image 70
Panasonic MN1030 user manual Example subroutine call converted to a relative branch