LDX

From NES Hacker Wiki
Revision as of 12:36, 11 April 2014 by TheAlmightyGuru (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Load X Index With Memory
Opcode: LDX
Operation: M → X
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

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.

Operation

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 A1 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.

Examples