Assembler Syntax
Source Line
MCUez HC12 Assembler User’s Manual
MOTOROLA Assembler Syntax 143
7.4.3.15 Indexed-Indirect, D Accumulator Offset
This addressing mode adds the value in D to the base index register. This forms
the memory address containing a pointer to the memory location referenced in
the instruction. The base index register may be X, Y, SP, or PC.
Example:
entry1: NOP
NOP
entry2: NOP
NOP
entry3: NOP
NOP
main:
LDD #2
JMP [D, PC]
goto1: DC.W entry1
goto2: DC.W entry2
goto3: DC.W entry3
This example represents a jump table. The values beginning at goto1 are
potential destinations for the jump instruction.
When JMP [D, PC] is executed, PC points to goto1 and D holds the
value 2.
The JMP instruction adds the value in Dand PC to form the address of goto2.
The CPU reads the address stored there (the address of label entry2) and jumps
to that location.