Chapter 4 Optimization

Optimization processing of conditional branch instructions

The linker resolves address values for labels when linking multiple files. In the example below, the linker will determine whether or not the label coded as an operand is within the allowable range of the current instruction. If not in range, the linker will replace it with instructions for a wider branch range.

Take the BEQ instruction for example.

BEQLABEL

......

LABEL

The destination label of the BEQ instructions must be in the range -128 to +127. However, the assembler cannot make that determination, so the following determinations are made during assembly and linking.

Assembler processing

The assembler outputs information about instructions to be optimized to the linker.

Linker processing

1.The linker inputs information from the assembler.

2.The linker determines if the branch destinations of conditional branches are in range.

3.If determined to be in range, the linker generates the normal code.

4.If determined to be not in range, the linker will substitute code that can branch correctly.

The substitution for the above example would be as follows.

BNE*+5

JMPLABEL

......

LABEL

50 Usage Example

Page 62
Image 62
Panasonic MN1030 Optimization processing of conditional branch instructions, Assembler processing, Linker processing