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