Zero-page addressing mode names a memory operand in the first 256 bytes of memory. A direct zero-page address uses an 8-bit offset, unlike absolute addressing, which supplies a full 16-bit address. Use it when an instruction should read from or write to a location such as $06 rather than an address such as $0300. section 3.3.2 section 4.1.1
For stores, the register named by the instruction supplies the value and the zero-page location is the destination. `STA $06`, `STX $07`, and `STY $08` place the contents of A, X, and Y into those first-page locations. Inspecting memory after running the instructions verifies the bytes at $06 through $08. section 3.3.2
lda #$10 sta $06 ldx #$11 stx $07 ldy #$12 sty $08
This short listing shows direct zero-page stores from all three general registers: A to $06, X to $07, and Y to $08. section 3.3.2
Zero-page forms also work with index registers and indirect addresses:
- Zero-page indexed addressing adds X or Y to an 8-bit starting address. For example, with X = $01, `STA $01,X` stores A at $02. section 3.3.2
- Zero-page indirect indexed with Y uses two zero-page bytes as a base address, then adds Y to select the final destination or source address. section 3.3.2
- Indexed indirect with X first uses X to select the zero-page location holding a two-byte base address. section 3.3.2
Add a value stored at $06
A zero-page address can be a source operand as well as a destination. Store $10 at $06, clear carry, load A with $04, then use `ADC $06`. The processor adds the byte from $06 to A, leaving A equal to $14. section 4.1.1
Listing 4.4 Adding a value from a zero-page address
Lda #$10 sta $06 clc lda #$04 adc $06
The listing provides a complete run-ready example of storing a value at $06 and adding it to A with `ADC $06`. section 4.1.1
