Zero-page indirect-X addressing mode uses X to choose where a two-byte address is stored in zero-page memory. Add X to the instruction’s 8-bit zero-page offset first; read the low byte and then the high byte from that resulting zero-page location; combine them into an absolute address; then use that address for the load, store, or arithmetic operation. section 3.3.1 section 4.1.1
Its assembly form places the zero-page address and X inside rounded brackets: `LDA (<zero-page address>,X)`. The brackets mean that zero-page memory supplies an address rather than the final data location. Unlike indirect addressing indexed by Y, X changes the location of the pointer before the two-byte address is read. section 3.3.1 section 4.1.1
Resolve `($02,X)` in small steps:
- Load X with `$03`. Adding it to the base offset `$02` selects zero-page location `$05`. section 3.3.1
- Read the adjacent bytes at `$05` and `$06`. With `$00` first and `$03` second, they form address `$0300` in least-significant-byte-first order. section 3.3.1
- Use `$0300` as the final location. `LDA ($02,X)` loads its value into A; `STA ($02,X)` writes A’s value there. section 3.3.1 section 3.3.2
Load, store, and add through the selected pointer
Set zero-page `$05` to `$00` and `$06` to `$03`, so they point to `$0300`. With `LDX #$03`, the operand `($02,X)` selects that pointer. If `$0300` contains `$EE`, `LDA ($02,X)` leaves A as `$EE`. With A already `$EE`, `STA ($02,X)` writes `$EE` to `$0300`. The same address lookup works for `ADC ($01,X)`: when X makes the pointer begin at `$02`, a `$12` at `$0300` is added to A’s `$10`, producing `$22`. section 3.3.1 section 3.3.2 section 4.1.1
Figure 3.7 Loading data into a register
Follow the diagram to separate the two address calculations: base offset plus X chooses the zero-page pointer, then that pointer chooses the final memory location. section 3.3.1
