Difference between revisions of "LDA"

From NES Hacker Wiki
Jump to: navigation, search
Line 11: Line 11:
 
}}
 
}}
  
 +
'''''LDA (Load Accumulator With Memory)''''' is probably the most-used [[opcode]] in 6502 assembly as it loads the most-used register, the [[accumulator]], with memory.
 +
 +
==Operation==
 +
This pseudo C code shows how the LDA opcode functions.
 +
 +
SET_NEGATIVE(Operand);        // Clears the N Status Bit if the Operand is $#00-7F, otherwise sets it.
 +
SET_ZERO(Operand);            // Sets the Z Status Bit if the Operand is $#00
 +
ACCUMULATOR = Operand;        // Stores the Operand in the Accumulator Register.
 +
 +
==Addressing Modes==
 
{{OpcodeHeader}}
 
{{OpcodeHeader}}
 
{{OpcodeLine|Immediate|LDA ''#Operand''|A9|2|2}}
 
{{OpcodeLine|Immediate|LDA ''#Operand''|A9|2|2}}
Line 22: Line 32:
 
{{OpcodeFooter|* Add 1 if page boundary is crossed.}}
 
{{OpcodeFooter|* Add 1 if page boundary is crossed.}}
  
'''''LDA''''' (Load Accumulator With Memory)
+
==Examples==

Revision as of 17:05, 23 May 2013

Load Accumulator With Memory
Opcode: LDA
Operation: A + M + C → A, C
Status Register: Status-List.png
Status-Change.pngStatus-Space.pngStatus-Change.pngStatus-Space.pngStatus-Change.pngStatus-Space.pngStatus-Ignore.pngStatus-Space.pngStatus-Ignore.pngStatus-Space.pngStatus-Change.png

LDA (Load Accumulator With Memory) is probably the most-used opcode in 6502 assembly as it loads the most-used register, the accumulator, with memory.

Operation

This pseudo C code shows how the LDA opcode functions.

SET_NEGATIVE(Operand);        // Clears the N Status Bit if the Operand is $#00-7F, otherwise sets it.
SET_ZERO(Operand);            // Sets the Z Status Bit if the Operand is $#00
ACCUMULATOR = Operand;        // Stores the Operand in the Accumulator Register.

Addressing Modes

Addressing Mode Assembly Language Form Opcode # Bytes # Cycles
Immediate LDA #Operand A9 2 2
Zero Page LDA Operand A5 2 3
Zero Page, X LDA Operand, X B5 2 4
Absolute LDA Operand AD 3 4
Absolute, X LDA Operand, X BD 3 4*
Absolute, Y LDA Operand, Y B9 3 4*
(Indirect, X) LDA (Operand, X) A1 2 6
(Indirect), Y LDA (Operand), Y B1 2 5*
* Add 1 if page boundary is crossed.

Examples