Indexed-indirect addressing

From C64-Wiki
Jump to navigationJump to search

In this rarely used Addressing mode, the X index register is used to offset the zero page vector used to determine the effective address. Put another way, the vector is chosen by adding the value in the X index register to the given zero page address. The resulting zero page address is the vector from which the effective address is read.

Indexed-indirect addressing is written as follows:

     LDX #$04
     LDA ($02,X)

In the above case, X is loaded with four (4), so the vector is calculated as $02 plus four (4). The resulting vector is ($06). If zero page memory $06 contains 00 80, then the effective address from the vector (06) would be $8000.

This addressing mode would only be useful to select a vector from an array of zero page vectors, and as such is very rarely used.

The following 8 machine language instructions support indexed-indirect addressing: ADC, AND, CMP, EOR, LDA, ORA, SBC, STA.