LDA

From C64-Wiki
Jump to navigationJump to search

LDA (short for "LoaD Accumulator") is the mnemonic for a machine language instruction which retrieves a copy from the specified RAM or I/O address, and stores it in the accumulator. The content of the memory location is not affected by the operation.

Addressing modes[edit | edit source]

Opcode Addressing
mode
Assembler
format
Length
in bytes
Number of
cycles
Dec Hex
169 A9 Immediate LDA #nn 2 2
173 AD Absolute LDA nnnn 3 4
189 BD Absolute,X LDA nnnn,X 3 4*
185 B9 Absolute,Y LDA nnnn,Y 3 4*
165 A5 Zeropage LDA nn 2 3
181 B5 Zeropage,X LDA nn,X 2 4
161 A1 Indexed-indirect LDA (nn,X) 2 6
177 B1 Indirect-indexed LDA (nn),Y 2 5*

LDA supports eight different addressing modes, as shown in the table at right. In the assembler formats listed, nn represents a single-byte (8-bit) figure, and nnnn is a two-byte (16-bit) address.
With some addressing forms (marked with an asterisk, *, in the "Number of cycles" column) the execution time for LDA depends on the circumstances: In cases where the indexing requires the CPU to "reach across" a page boundary from the base address, the execution time is 1 cycle longer than listed here.

CPU flags[edit | edit source]

LDA affects 2 of the CPU's status flags:

  • The negative status flag is set if the result is negative, i.e. has it's most significant bit set.
  • The zero flag is set if the result is zero, or cleared if it is non-zero.