LDA loads a value into the 6502 accumulator, A. The value can come directly from the assembly listing or from memory. Its operand syntax selects the addressing mode: `#` means use the written value; without it, LDA reads memory. section 3.3.1
Choose an LDA form by where the value lives:
- `lda #$05` loads the immediate value 5 into A. section 3.3.1
- `lda $05` reads a value from zero-page memory; `lda $0300` reads from an absolute memory address. section 3.3.1
- `lda $01,X` and `lda $0300,X` add X to a zero-page or absolute base address before reading. section 3.3.1
- `lda ($05),Y` and `lda ($02,X)` use zero-page locations to calculate a memory address. section 3.3.1
Load from zero-page memory
Store `$10` at `$05`, then run `lda $05`. A receives `$10`. Compile and run the sequence in a simulator, then check the debug display to verify A changed as expected. section 3.3.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 the available addressing modes to see how an LDA operand identifies its source value or memory location. section 3.3.1
