A low byte is the less significant eight-bit portion of a multi-byte numeric value. In a 16-bit address, it is stored separately from the high byte; 6502 systems commonly place the low byte first. section 3.3.1 section 6.3
Use the low byte when splitting or reconstructing a 16-bit address:
- Extract it with the assembler's < symbol, as in lda #<value. section 6.3
- Store it at the first byte of a two-byte zero-page address, then store the high byte at the next location. section 3.3.1 section 6.3
- Write the low byte first when setting the NES PPU address register, followed by the high byte. section 6.3
Assigning a 16-bit address
For assign_16i dest, value, lda #<value loads the low byte and stores it at dest+0. Then lda #>value loads the high byte and stores it at dest+1. Passing $2000 therefore expands into separate byte operations while keeping the call compact. section 6.3
Listing 6.6 Starting a macros file (macros.s)
.macro vram_set_address newaddress lda PPU_STATUS lda #>newaddress sta PPU_VRAM_ADDRESS2 lda #<newaddress sta PPU_VRAM_ADDRESS2 .endmacro
Inspect the macro that extracts the low and high bytes of a supplied address before writing them to the PPU. section 6.3
