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