Changes

Jump to: navigation, search

6502 Addressing Modes

844 bytes added, 23:03, 13 September 2023
no edit summary
[[Category:6502]]
The [[6502]] processor has 13 [[Addressing Mode|Addressing Modes]], which affect how the arguments for instructions are accessed. Not  For example, the Load Accumulator <code>LDA</code> instruction can load the accumulator from different sources:  LDA #$05 ; Immediate addressing mode - load the accumulator with the number 5 LDA $05 ; Zero-page addressing mode - load the accumulator from memory address 5 LDA $0805 ; Absolute addressing mode - load the accumulator from memory address 0x8005 (32773). These are the available addressing modes on the 6502 processor; note that not all addressing modes are valid for every instruction.:
== Accumulator ==
== Absolute, Y ==
Data is accessed using a 16-bit address specified as a constant, to which the value of the X Y register is added (with carry).
LDA $8000,y
== X, Indirect ==
An 8-bit zero-page address and the X register are added, without carry (if the addition overflows, the address wraps around within page 0). The resulting address is used as a pointer to the data being accessed. Note that, effectively, this makes the X register an index into a list of pointers. Also note that pointers are two bytes long, so the X register should be an even number when accessing a list of pointers (otherwise you'll get half of one pointer and half of another).
LDA ($05,x) ; if x=4, then the pointer at $09 (and $0a) will be used, and the accumulator loaded from the address indicated by the pointer
== Zero page ==
An 8-bit address is provided within the zero page. This is like an absolute address, but since the argument is only one byte, the CPU does not have to spend an additional cycle to fetch high byte.
LDX $13

Navigation menu