Home Page


6502 Addressing Modes

The 6502 makes up for not having as many general purpose registers by the use of different addressing modes. An address mode will allow the 6502 to interpret an opcode in such a fashion where the CPU can leverage main memory addresses as register indices.

Here are the various addressing modes of the 6502:

Addressing Mode Example
Implied The opcode mnemonic is self explanatory.

Ex: DEX

Accumulator Operates on the Accumulator (A) register context.

Ex: ASL A

Immediate A byte will be interpreted literally.

Ex: LDA #$55

Absolute The given operand is a 16 bit address with the first byte being the LOW byte of the address and the second byte being the HIGH byte of the address.

Ex: LDA $2000

Program Counter Relative The given operand byte is an 8 bit relative address of the current address in the program counter.

Ex: BEQ LABEL12

where LABEL12 is a offset in the range of -128 to 127.

Stack Use the stack pointer to operate at a 16 bit address.

Ex: PHA

Will use the value stored in the S register, a 16 bit value, and store the contents of A into that memory location.

Zero Page Similar to Absolute Addressing, except it only uses a byte. So, the address is going to be at the first 256 locations in memory.

Ex: LDA $81

Absolute Indexed with X The operand is a 16-bit address that will be added to the X register to form the effective address.

Ex: LDA $2000, X

Suppose X=$8, then the effective address to load the contents of A into memory will be:

$2000 + $8 = $2008

Absolute Indexed with Y The operand is a 16-bit address that will be added to the Y register to form the effective address.

Ex: LDA $2000, Y

Suppose Y=$B, then the effective address to load the contents of A will be:

$2000 + $B = $200B

Zero Page Indexed with X Similar to Absolute Indexed with X, except with an 8 bit address.

Ex: LDA $55, X

Zero Page Indexed with Y Similar to Absolute Indexed with Y, except with an 8 bit address.

Ex: LDA $55, Y

Absolute Indirect The given 16-bit address is the memory address in which points to real address in memory.

LOC(X) = High Byte of the Address

LOC(X+1) = Low byte of the Address

Ex: JMP ($1020)

Zero Page Indirect Indexed with Y (Postindexed) Use the 8 bit byte operand as the base address to find the location in memory, the contents of the effective address (16 bit, 2 bytes), then add the value stored in Y to it to form the final address.

Ex: LDA ($55), Y

Zero Page Indexed Indirect with X (Preindexed) Use the 8 bit byte operand as the base address, then add the value stored in X to find the location in memory, the contents of the effective address (16 bit, 2 bytes).

Ex: LDA ($55, X)

Source: Programming the 65816. Including the 6502, 65C02 and 65802. David Eyes and Ron Lichty.


Previous: 6502 Registers