Difference between revisions of "Indexed Addressing"

From NES Hacker Wiki
Jump to: navigation, search
m (typo: "ton" => "to)
 
Line 1: Line 1:
In '''''Indexed Addressing''''' is similar to [[Zero-Page Indexed Addressing]], except that in ''Indexed Addressing'' you have ton include full 2-byte address. In this mode, the address is added to the value either by the X or Y index register. Most opcodes support the X index register for the offset, but an additional handful also support the Y index register.
+
In '''''Indexed Addressing''''' is similar to [[Zero-Page Indexed Addressing]], except that in ''Indexed Addressing'' you have to include full 2-byte address. In this mode, the address is added to the value either by the X or Y index register. Most opcodes support the X index register for the offset, but an additional handful also support the Y index register.
  
 
The benefit of ''Indexed'' addressing is that you can quickly loop through memory by simply increasing or decreasing the offset.
 
The benefit of ''Indexed'' addressing is that you can quickly loop through memory by simply increasing or decreasing the offset.

Latest revision as of 02:27, 21 March 2015

In Indexed Addressing is similar to Zero-Page Indexed Addressing, except that in Indexed Addressing you have to include full 2-byte address. In this mode, the address is added to the value either by the X or Y index register. Most opcodes support the X index register for the offset, but an additional handful also support the Y index register.

The benefit of Indexed addressing is that you can quickly loop through memory by simply increasing or decreasing the offset.


Examples

This example uses Indexed Addressing to store #$7F into all the memory from 1000-10FF. Line 0005 uses Indexed Addressing.

0001:A9 7F     LDA #$7F         ; Load A with 7F.
0003:A2 FF     LDX #$FF         ; Load X with FF.
0005:9D 00 10  STA $1000,X      ; Store A into $1000 offset with X.
0008:CA        DEX              ; Decrement X.
0008:30 FB     BPL $0005        ; Goto $0005 while X is not -1.


Opcodes

Since Indexed addressing can be both on the X and Y index registers, both are listed here separately.

X Index Register

The following opcodes support Indexed addressing using the X index register:

Y Index Register

The following opcodes support Indexed addressing using the Y index register: