Code: Select all
Zero-Page Indexed This works just like absolute indexed, but the target address is limited to the first 0xFF bytes. The target address will wrap around and will always be in the zero page. If the instruction is LDA $C0,X, and X is $60, then the target address will be $20. $C0+$60 = $120, but the carry is discarded in the calculation of the target address. Indexed Indirect This mode is only used with the X register. Consider a situation where the instruction is LDA ($20,X), X contains $04, and memory at $24 contains 0024: 74 20, First, X is added to $20 to get $24. The target address will be fetched from $24 resulting in a target address of $2074. Register A will be loaded with the contents of memory at $2074. If X + the immediate byte will wrap around to a zero-page address. So you could code that like targetAddress = (X + opcode) & 0xFF . Indexed Indirect instructions are 2 bytes - the second byte is the zero-page address - $20 in the example. Obviously the fetched address has to be stored in the zero page. Indirect Indexed This mode is only used with the Y register. It differs in the order that Y is applied to the indirectly fetched address. An example instruction that uses indirect index addressing is LDA ($86),Y . To calculate the target address, the CPU will first fetch the address stored at zero page location $86. That address will be added to register Y to get the final target address. For LDA ($86),Y, if the address stored at $86 is $4028 (memory is 0086: 28 40, remember little endian) and register Y contains $10, then the final target address would be $4038. Register A will be loaded with the contents of memory at $4038. Indirect Indexed instructions are 2 bytes - the second byte is the zero-page address - $20 in the example. (So the fetched address has to be stored in the zero page.) While indexed indirect addressing will only generate a zero-page address, this mode's target address is not wrapped - it can be anywhere in the 16-bit address space.
This might explain why I couldn't solve the ExciteBike Turbo GG connection.. because I was trying to find "BC C0", but could of easily been another address that connects the two.