LDY (LoaD Y register)¶
Y = [operand]
LDY (LoaD Y register) is an instruction that loads a value from memory into the Y register. The operand can be either an immediate value, a memory location specified by its address, or a memory location specified by an indexed indirect or indirect indexed address.
The result is stored in the Y register, and the Zero and Negative flags are set based on the result.
Addressing Modes¶
Mode |
Syntax |
Bytes |
Cycles |
---|---|---|---|
LDY #const |
|
2 |
|
LDY zp |
|
3 |
|
LDY zp,x |
|
4 |
|
LDY addr |
|
4 |
|
LDY addr,x |
|
4-5 |
Flags Affected¶
N (Negative) – Set if the loaded value has the most significant bit set (i.e., is negative); otherwise, it is cleared.
Z (Zero) – Set if the loaded value is zero; otherwise, it is cleared.
Examples¶
Load a Constant into the Y Register¶
LDY #10 ; load Y with constant 10
Load a Value from a Memory Location¶
LDY $20 ; load Y with the value at memory location $20
Load a Value from a Memory Location with an Offset¶
LDX #2 ; load X with 2
LDY $10,X ; load Y with the value at memory location $12 ($10 + X)
See Also¶
LDA (LoaD Accumulator)
STA (STore Accumulator)
LDX (LoaD X register)