This addressing mode is generally used to transfer tables addressed by the index register to a register in page zero.
The operand addressed by the HX index register is stored in the direct page location addressed by the byte following the opcode. The HX index register is automatically incremented. The A register is not affected. See the following listing for an example of using the memory-to-memory indexed to direct with post-increment addressing mode.
XDEF Entry ConstSCT: SECTION Const: DC.B 1,11,21,31,192,12,0 DataSCT: SECTION SHORT MyReg: DS.B 1 CodeSCT: SECTION Entry: LDHX #$00FF TXS main: LDHX #Const LOOP: MOV X+, MyReg BEQ main BRA LOOP
In this example, the table Const contains seven bytes defined in a constant section in ROM. The last value of this table is zero.
The HX register is initialized with the address of Const. All the values of this table are stored one after another in page-zero memory location MyReg using the MOV X+, MyReg instruction. When the value 0 is encountered, the HX register is reset with the address of the first element of the #Const table.