A memory mode, also called an addressing mode, tells a 6502 instruction whether its operand is a literal value or a memory location, and how that location is found. Load instructions move a selected value into A, X, or Y; store instructions move a register value to the selected destination. section 3.3.1 section 3.3.2
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. |
Use this table as a quick map of the load forms before trying each syntax pattern. section 3.3.1
The main forms build from direct locations to calculated addresses:
- Immediate mode uses a number written in the instruction. A leading # means “use this value,” as in lda #$05. section 3.3.1
- Zero-page mode names an address from $00 through $FF; without #, lda $05 reads the value stored at location $05. section 3.3.1
- Absolute mode supplies a full 16-bit address, such as lda $0300 or sta $0300. section 3.3.1 section 3.3.2
- Indexed modes add X or Y to a zero-page or absolute base address, allowing one instruction pattern to reach a shifted location. section 3.3.1 section 3.3.2
- Indirect indexed forms use two zero-page bytes as a base address, then apply an index register to reach the final location. section 3.3.1 section 3.3.2
Distinguishing a value from an address
First place $10 in A, then store it at zero-page address $05. `lda #$10` loads the literal $10; `sta $05` writes it to memory; `lda $05` reads that stored value back into A. The # character changes what $05 means to the assembler. section 3.3.1 section 3.3.2
For stores, the register is the source and memory is the destination. Store forms use zero-page, absolute, indexed, and indirect addressing to choose where A, X, or Y is written; the available form depends on the instruction and register. section 3.3.2
