Chapter 4 Optimization

Table 4-8 Substituted Instructions For Out-Of Range Conditional Branch Instructions

Source Instruction

Candidate instruction 1

Candidate instruction 2

Candidate instruction 3

 

 

 

 

BLT LABEL

BRA LABEL

BGE *+5

BGE *+7

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BGT LABEL

BGT LABEL

BLE *+5

BLE *+7

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BGE LABEL

BGE LABEL

BLT *+5

BLT *+7

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BLE LABEL

BLE LABEL

BGT * +5

BGT *+7

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BCS LABEL

BCS LABEL

BCC *+5

BCC *+7

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BHI LABEL

BHI LABEL

BLS *+5

BLS *+7

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BCC LABEL

BCC LABEL

BCS *+5

BCS *+7

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BLS LABEL

BLS LABEL

BHI *+5

BHI *+7

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BEQ LABEL

BEQ LABEL

BNE *+5

BNE *+7

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BNE LABEL

BNE LABEL

BEQ *+5

BEQ *+7

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BVC LABEL

BVC LABEL

BVS *+6

BVS *+8

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BVS LABEL

BVS LABEL

BVC *+6

BVC *+8

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BNC LABEL

BNC LABEL

BNS *+6

BNS *+8

 

 

JMP LABEL

JMP LABEL

 

 

 

 

BNS LABEL

BNS LABEL

BNC *+6

BNC *+8

 

 

JMP LABEL

JMP LABEL

 

 

 

 

Optimization of branches

For unconditional branch instructions, a JMP label instruction is replaced by a BRA label instruction if the jump target is within the range available for the shorter, relative branch instruction BRA. Similarly, a CALL label, CALLS label, or JSR label instruction is replaced by the shorter version with a 16-bit displacement (d16,PC) instead of the one with the 32-bit displacement (d32,PC).

The following table shows the possibilities for optimizing the unconditional branch instructions and the subroutine call instructions.

Table 4-9 Optimization of branches

Source Instruction

First Candidate

Second Candidate

Third Candidate

 

 

 

 

 

BRA label

BRA

label

JMP label

JMP label

JMP label

BRA

label

JMP label

JMP label

CALL label

CALL label

CALL label

 

CALLS label

CALLS label

CALLS label

 

JSR label

JSR

label

JSR label

 

52 Usage Example

Page 64
Image 64
Panasonic MN1030 user manual Optimization of branches, BRA label, Label JMP label Call label Calls label JSR label