Difference between revisions of "LDX"

From NES Hacker Wiki
Jump to: navigation, search
Line 22: Line 22:
==Addressing Modes==
==Addressing Modes==
{{OpcodeLine|Immediate|LDX ''#Operand''|A1|2|2}}
{{OpcodeLine|Immediate|LDX ''#Operand''|A2|2|2}}
{{OpcodeLine|Zero Page|LDX ''Operand''|A6|2|3}}
{{OpcodeLine|Zero Page|LDX ''Operand''|A6|2|3}}
{{OpcodeLine|Zero Page, X|LDX ''Operand, X''|B6|2|4}}
{{OpcodeLine|Zero Page, X|LDX ''Operand, X''|B6|2|4}}

Latest revision as of 08:20, 1 December 2017

Load X Index With Memory
Opcode: LDX
Operation: M → X
Status Register: Status-List.png

LDX (Load X Index With Memory) loads the X Index Register with the specified memory. It is similar in function to LDA and LDY opcodes. Unlike LDA, there aren't as many addressing modes available for LDX.


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

SET_NEGATIVE(Operand);        // Sets the Negative Flag equal to the 7th bit.
SET_ZERO(Operand);            // Sets the Zero Flag if the Operand is $#00, otherwise clears it.
X_INDEX = Operand;            // Stores the Operand in the X Index Register.

Addressing Modes

Addressing Mode Assembly Language Form Opcode # Bytes # Cycles
Immediate LDX #Operand A2 2 2
Zero Page LDX Operand A6 2 3
Zero Page, X LDX Operand, X B6 2 4
Absolute LDX Operand AE 3 4
Absolute, X LDX Operand, X BE 3 4*
* Add 1 if page boundary is crossed.