User guide

Indexed absolute addressing (aka Absolute, X or Y addressing)
Indexed zero page addressing (aka Zero page, X addressing)
<instruction> <address>, X
<instruction> <address>, Y
This behaves much like the Absolute / Zero page addressing previously described, however in
addition to retrieving the address, the contents of the X or Y register (as applicable) is added.
For example:
LDX &DD ; set X to &DD
LDA #&F000, X ; load A from (&F000
; + &DD)
The zero-page versions work entirely in zero page, so adding &FF to &FF won’t work. The
effective address would be &FE.
Examples:
CMP &FE02, Y ; compare A with byte
; at (&FE02 + Y)
LDA &C5, X ; load A from &C5
; ==ZERO PAGE==
Zero page, Y addressing
LDX <value>, Y
STX <value>, Y
There is, generally, no such thing as Zero page, Y addressing as the zero page indexed addressing
uses the X register.
The specific exception to the rule is when we are loading and saving the X register – we can’t
indirect it with itself!
Examples:
LDX &0F, Y
STX 123, Y
Indexed indirect addressing (pre-indexed)
<instruction> (<zero page address>, X)
Ready? The contents of the second byte of the instruction are added to the X register. This then
gives us an address in page zero where we can expect to find our ‘real’ target address.
This addressing mode is mainly used for interfacing multiple peripherals. You can store a list of
pointers in memory, and by using base address + index, you can read data from each
peripheral in turn simply by repeating the same code using the index register to select which to
load.
6502asm user guide – prerelease version
page 13