This addressing mode is useful when selecting the k-th element in an n-element table. The size of the table is limited to 256 bytes.
Indexed, 8-bit offset instructions are two byte long. The first byte is the opcode and the second byte contains the index register offset byte. See the following listing for an example of using the indexed (8-bit offset) addressing mode.
XDEF Entry initStack: EQU $0400 MyData: SECTION SHORT data: DS.B 8 MyCode: SECTION Entry: LDHX #initStack ; init Stack Pointer TXS ; with value $400-1 = $03FF main: LDHX #data LDA 5 ,X ... JMP $FF,X ...
The value contained in the memory at the location calculated using the address of data (pointed to by the HX register) + 5 is loaded in accumulator A. The JMP instruction causes the program to jump to the address pointed to by the HX register + $FF.