liveBook · Manning

Immediate value

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

An immediate value is a constant operand encoded directly in an assembly instruction rather than read from a memory address.

An immediate value is a numerical value written directly in an assembly instruction. Prefix it with # to tell the assembler to use that number rather than treat it as a memory location. section 3.3.1

Load 5 directly

Use lda #$05, ldx #$05, or ldy #$05 to place the value 5 into A, X, or Y. Omitting # changes $05 into a zero-page memory location to read from instead. section 3.3.1

lda #$05        #1
ldx #$05
ldy #$05

This listing shows the same immediate value loaded into all three registers. section 3.3.1

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

How deep it goes
Defines # syntax and contrasts immediate loading with zero-page memory loading.
Examples
Uses $05 loaded into A, X, and Y, then contrasts reading address $05.
What it assumes
Introduces register targets and direct numerical operands without requiring prior assembly syntax.
What you can do after
Apply it via 6502 load instructions to place a chosen number in a register.
How it connects
Connects addressing modes with registers, zero-page memory, and load instructions.

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.