Indexed with post-increment

The operand is addressed then the HX register is incremented.

This addressing mode is useful for searches in tables. It is only used with the CBEQ instruction. See the following listing for an example of an example of using the indexed with post-increment addressing mode.

Listing: Example of the indexed with post-increment addressing mode
          XDEF Entry
          ORG   $F000

data:     DC.B  1,11,21,31,$C0,12

CodeSCT:  SECTION

Entry:    LDHX  #$00FF

          TXS

main:

          LDA   #$C0

          LDHX  #data

LOOP:     CBEQ  X+,IS_EQUAL

          BRA   LOOP

IS_EQUAL: ...

Using this addressing mode, it is possible to scan the memory to find a location containing a specific value.

The value located at the memory location pointed to by HX is compared to the value in the A register. If the two values match, the program branches to IS_EQUAL. HX points to the memory location next to the one containing the searched value.

In this example, the value $C0 is searched starting at memory location $F000. This value is found at the memory location $F004, the program branches to IS_EQUAL, and the HX register contains $F005.