Zero-page indexed addressing mode reads or writes through a location in the first 256 bytes of memory after adding an index register value to a zero-page base address. Write the base as an 8-bit address, then use X or Y as the offset: the calculated result is the zero-page location used by the instruction. section 3.3.1 section 3.3.2
This mode is useful when one base location stands for a small group of nearby values. Instead of naming every location separately, load an index into X or Y and let the instruction select the offset location. It differs from absolute indexed addressing because its starting address is in zero-page memory rather than a full 16-bit address. section 3.3.1 section 3.3.2
To use a zero-page indexed operand:
- Place or identify the value at the intended zero-page location. section 3.3.1
- Load X or Y with the offset from the base address. section 3.3.1
- Use the base address followed by the index register, such as $01,X; the processor adds them before loading or storing. section 3.3.1 section 3.3.2
- Assemble and run the code, then inspect the registers or zero-page memory to verify the calculated location. section 3.3.1 section 3.3.2
Load through a zero-page X offset
Store $20 at $03, set X to $02, and load from base $01 with lda $01,X. The effective address is $01 + $02 = $03, so A receives $20. The same address calculation can supply an operand to ADC: with $12 at $08, X = $02, and A = $10, adc $06,x produces $22. section 3.3.1 section 4.1.1
Indexed zero-page addressing also works for storing A-register data: with X set to $01, sta $01,x writes A to $02. Loads, stores, and arithmetic therefore reuse the same idea—calculate a zero-page address first, then perform the instruction’s operation there. section 3.3.2 section 4.1.1
Table 3.7 The available addressing modes (view table figure)
| Mode |
Description |
|---|---|
| Immediate |
The actual numerical value is specified immediately after the statement. |
| Zero-page memory |
The value is obtained from a location in zero-page memory using an 8-bit offset. |
| Absolute memory |
The value is obtained from anywhere in memory using a 16-bit memory address. |
| Zero-page index with X or Y |
The value is obtained from a location in zero-page memory by adding an 8-bit offset address to the value in either the X or Y index registers to get the final 8-bit offset. |
| Absolute memory indexed with X or Y |
The value is obtained from a location anywhere in memory starting at a specified 16-bit memory address and adding the value in either the X or Y index to determine the final memory address to get the value from. |
| Zero-page indirect indexed with Y |
The value is obtained from a location anywhere in memory starting at the base address stored in the specified 2 bytes of zero-page memory, and then the value in the Y register is added to that address to get the final address. |
| Zero-page Indexed indirect with X |
The value is obtained from a location anywhere in memory starting at the base zero-page offset and adding the value in the X register to get the location in zero-page memory where the final address is specified in 2 bytes of memory. |
Compare zero-page indexed addressing with immediate, direct zero-page, absolute, absolute indexed, and indirect indexed modes. section 3.3.1
