Chapter 4 Optimization

Example: branch destination of conditional branch instruction out of range

This example shows a branch outside the permitted range (-128 to +127 of PC) of a BCC LABEL con- ditional branch instruction.

The source list is as follows.

 

opt

on

_TEXT

section

CODE, PUBLIC,1

sub_func

mov

0, D2

 

 

cmp

D1, D2

addr_set

bcc

func_end

func_end

org

addr_set+128

rts

 

 

 

 

end

 

The final list file after assembly is shown next. LABEL exceeds the permitted branch range of BCC LA- BEL, so the code has been converted to BCS *+5, JMP LABEL. Note that the mnemonics and object code are different.

 

 

 

opt2.lst Page 1

 

Loc

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

Object

Line

Source

opt

on

 

 

1

_TEXT

40000000

 

2

 

section CODE, PUBLIC, 1

8A00

3

sub_func

mov

0, D2

40000000

4

 

40000002

A6

5

addr_set

cmp

D1, D2

40000003

C405CC0080

@6

bcc

func_end

 

 

7

 

org

addr_set+128

40000083

 

8

func_end

F0FC

9

rts

 

40000083

10

 

 

 

 

11

 

end

 

 

 

12

opt2.lst Page 2

 

 

 

 

 

*** Symbol Table

***

 

40000000

T

sub_func

40000003

T

addr_set

40000083

T

func_end

56 Usage Example

Page 68
Image 68
Panasonic MN1030 user manual Text