Difference between revisions of "LDA"

From NES Hacker Wiki
Jump to: navigation, search
(Created page with "{{Infobox Opcode | Title = Load Accumulator With Memory | Opcode = LDA | Operation = A + M + C → A, C | StatusN = Change | StatusZ = Change | StatusC = Change |...")
 
 
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
| Title    = Load Accumulator With Memory
 
| Title    = Load Accumulator With Memory
 
| Opcode    = LDA
 
| Opcode    = LDA
| Operation = A + M + C → A, C
+
| Operation = M → A
 
| StatusN  = Change
 
| StatusN  = Change
 
| StatusZ  = Change
 
| StatusZ  = Change
| StatusC  = Change
+
| StatusC  = Ignore
 
| StatusI  = Ignore
 
| StatusI  = Ignore
 
| StatusD  = Ignore
 
| StatusD  = Ignore
| StatusV  = Change
+
| StatusV  = Ignore
 
}}
 
}}
 +
 +
'''''LDA (Load Accumulator With Memory)''''' loads the [[Accumulator Register|accumulator]] with specified memory. It is probably the most-used [[opcode]] in 6502 assembly as it loads the most-used register. It is similar in function to [[LDX]] and [[LDY]].
 +
 +
==Operation==
 +
This pseudo C code shows how the LDA opcode functions when it is executed.
 +
 +
SET_NEGATIVE(Operand);        // Clears the [[Negative Flag]] if the Operand is $#00-7F, otherwise sets it.
 +
SET_ZERO(Operand);            // Sets the [[Zero Flag]] if the Operand is $#00, otherwise clears it.
 +
ACCUMULATOR = Operand;        // Stores the Operand in the Accumulator Register.
 +
 +
==Addressing Modes==
 +
{{OpcodeHeader}}
 +
{{OpcodeLine|Immediate|LDA ''#Operand''|A9|2|2}}
 +
{{OpcodeLine|Zero Page|LDA ''Operand''|A5|2|3}}
 +
{{OpcodeLine|Zero Page, X|LDA ''Operand, X''|B5|2|4}}
 +
{{OpcodeLine|Absolute|LDA ''Operand''|AD|3|4}}
 +
{{OpcodeLine|Absolute, X|LDA ''Operand, X''|BD|3|4*}}
 +
{{OpcodeLine|Absolute, Y|LDA ''Operand, Y''|B9|3|4*}}
 +
{{OpcodeLine|(Indirect, X)|LDA ''(Operand, X)''|A1|2|6}}
 +
{{OpcodeLine|(Indirect), Y|LDA ''(Operand), Y''|B1|2|5*}}
 +
{{OpcodeFooter|* Add 1 if page boundary is crossed.}}
 +
 +
==Examples==

Latest revision as of 14:28, 24 May 2013

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

LDA (Load Accumulator With Memory) loads the accumulator with specified memory. It is probably the most-used opcode in 6502 assembly as it loads the most-used register. It is similar in function to LDX and LDY.

Operation

This pseudo C code shows how the LDA opcode functions when it is executed.

SET_NEGATIVE(Operand);        // Clears the Negative Flag if the Operand is $#00-7F, otherwise sets it.
SET_ZERO(Operand);            // Sets the Zero Flag if the Operand is $#00, otherwise clears it.
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