Post-Indexed Indirect Addressing

From NES Hacker Wiki
Revision as of 17:53, 3 May 2013 by TheAlmightyGuru (talk | contribs) (Created page with "'''''Post-Indexed Indirect Addressing''''' is one of the three Indirect addressing modes of the 6502 processor. This mode is similar to Pre-Indexed Indirect Addressing, ho...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Post-Indexed Indirect Addressing is one of the three Indirect addressing modes of the 6502 processor. This mode is similar to Pre-Indexed Indirect Addressing, however, unlike the pre-indexed mode, where the X-register is added to the operand prior to reading from memory, post-indexed mode adds the Y-register after reading from memory. The address is expected to contain a 2-byte pointer to a memory address (in little-endian, of course). The indirection is indicated by parenthesis in assembly language, notice that, unlike pre-indexed mode, they don't encompass the Y, signifying that the addition occurs after the read.

This instruction is a three step process.

  1. Read the 2-byte address based on the operand.
  2. Sum the address and the Y-register to get the offset address.
  3. Return the value found in the offset address.

Note: I'm not sure what happens when you use #FF as you operand. I would assume, since this is a zero-page operation, that the next byte would be read from #00, but it may also be read from #100.

Examples

This example loads the memory with a pointer and sets the Y-register to read the value from the pointer's address.

0001:A9 05     LDA #$15        ; The first four lines create a pointer value of 
0003:85 00     STA $46         ; $3215 and store it into $0046-$0047.
0005:A9 20     LDA #$32
0007:85 01     STA $47
0009:A9 FF     LDA #$FF        ; Load A with #FF.
0011:8D 15 32  STA $3219       ; Store A into address $3219.
0014:A2 05     LDY #04         ; Load the Y-register with #04.
0016:B1 40     LDA ($46), Y    ; Read the memory address located at $46.
                               ; The address there is $3215. Then, add the Y-register to it, which gives us $3219.
                               ; So A will be loaded with #FF.


Opcodes

The following opcodes support post-indexed indirect addressing: