liveBook · Manning

Ldy instruction

As explained in Classic Game Programming on the NES: Make your own retro video game

The LDY instruction loads an operand into the 6502 Y register.

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

How Classic Game Programming on the NES: Make your own retro video game covers it

How deep it goes
Defines LDY syntax and illustrates immediate, zero-page, and absolute memory loading without detailing every LDY-specific addressing restriction.
Examples
Uses LDY #$05 and LDY $05 alongside matching A and X loads, with simulator register results.
What it assumes
Teaches loading from zero, introducing registers, operands, the # marker, and memory-source choices.
What you can do after
Apply it via the Online Assembler Simulator to load direct values or stored memory values into Y.
How it connects
Connects LDY to LDA, LDX, registers, immediate addressing, zero-page memory, and absolute memory.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Classic Game Programming on the NES: Make your own retro video game. The section links point to the parts of the book it draws on.