LDA
Load Accumulator
Data Transfer

Loads the accumulator (A) with a value from memory or an immediate constant. Sets the N and Z flags according to the value loaded.

⚙️

Operation

A ← M           ; Load A with the byte at the effective address M
N ← bit 7 of A  ; Set Negative flag if bit 7 is set
Z ← (A == 0)    ; Set Zero flag if result is zero
🚩

Processor Status Flags

NSet if result bit 7 = 1
VUnaffected
TUnaffected
BUnaffected
DUnaffected
IUnaffected
ZSet if A = $00
CUnaffected

Modified   Unaffected

📋

Addressing Modes & Opcodes

Addressing Mode Syntax Opcode Bytes Cycles Notes
Immediate LDA #$nn $A9 2 2 Load constant value
Zero Page LDA $nn $A5 2 3 Address $0000–$00FF
Zero Page, X LDA $nn,X $B5 2 4 ZP + X, wraps within ZP
Absolute LDA $nnnn $AD 3 4 Full 16-bit address
Absolute, X LDA $nnnn,X $BD 3 4+ +1 cycle if page crossed
Absolute, Y LDA $nnnn,Y $B9 3 4+ +1 cycle if page crossed
(Indirect, X) LDA ($nn,X) $A1 2 6 Pre-indexed indirect
(Indirect), Y LDA ($nn),Y $B1 2 5+ Post-indexed indirect; +1 if page crossed
💡

Examples

Example 1 — Load an immediate value

; Load the value $55 directly into A
LDA #$55         ; A = $55, N=0, Z=0

; Load zero, setting the Zero flag
LDA #$00         ; A = $00, N=0, Z=1

; Load a negative number (bit 7 set), setting the Negative flag
LDA #$80         ; A = $80, N=1, Z=0

Example 2 — Load from zero-page (used by the monitor program)

; From the board monitor disassembly — load the accumulator save area
LAB_B4  = $B4          ; accumulator save location in zero page
        LDA LAB_B4      ; restore A from the saved register image

Example 3 — Indexed load from a lookup table

; Read the Nth byte from a table using X as the index
        LDX #$03         ; X = 3 (4th entry)
        LDA TABLE,X     ; A = TABLE[3]
        RTS

TABLE:  .byte $10,$20,$30,$40,$50

Example 4 — Indirect indexed (pointer in zero page)

; LAB_B2/B3 holds the address pointer (low/high byte)
; Load the first byte at the address pointed to by (LAB_B2)
        LDY #$00
        LDA (LAB_B2),Y  ; A = memory[ word_at(LAB_B2) + Y ]
📝

Notes & Tips

  • LDA does not affect the Carry (C) or Overflow (V) flags. This is important when chaining multi-byte arithmetic — you can reload A without disturbing those flags.
  • Loading from zero page is one byte shorter and one cycle faster than loading from an absolute address — prefer zero-page locations for frequently accessed variables.
  • The (Indirect),Y mode is the most versatile for pointer-based access. The 740 monitor uses this mode extensively for memory examination (see Monitor Disassembly).
  • On the M50734SP, internal register addresses ($E4–$FF) are accessible to LDA just like normal RAM. You can read peripheral registers (e.g. UART status) using LDA with the appropriate address.
  • After LDA #$00, the Zero flag is set — useful for testing before branching with BEQ.
← LDX (Load X) Instruction Index STA (Store A) →