LDY loads a value into the 6502 Y register. Like LDA and LDX, it uses an LD instruction name followed by a source operand. The source may be a literal value or a memory location. section 3.3.1
Load an immediate value
Use # when the operand is the value itself: LDY #$05 After execution, Y contains $05 (decimal 5). Without #, a small operand such as $05 names a zero-page memory location instead. section 3.3.1
Load Y in small, explicit steps:
- Write LDY followed by # and a number to place that number directly in Y. section 3.3.1
- Write LDY followed by a memory address to copy the value stored at that address into Y. section 3.3.1
- Use a zero-page address for memory locations from $00 through $FF; omit # so the assembler reads memory rather than treating the operand as a literal. section 3.3.1
lda #$05 #1 ldx #$05 ldy #$05
Compare the three immediate load instructions to see that LDY follows the same pattern while targeting Y. section 3.3.1
