1
0
mirror of https://github.com/ariejan/i6502.git synced 2025-08-09 05:25:17 +00:00

Support indirect memory addressing mode

This commit is contained in:
Ariejan de Vroom
2014-08-09 10:38:46 +02:00
parent e20df11fd7
commit fdb6f81bc8

View File

@@ -97,6 +97,10 @@ func (c *Cpu) memoryAddress(in Instruction) uint16 {
case absoluteY: case absoluteY:
return in.Op16 + uint16(c.Y) return in.Op16 + uint16(c.Y)
case indirect:
location := uint16(in.Op16)
return c.Bus.Read16(location)
// Indexed Indirect (X) // Indexed Indirect (X)
// Operand is the zero-page location of a little-endian 16-bit base address. // Operand is the zero-page location of a little-endian 16-bit base address.
// The X register is added (wrapping; discarding overflow) before loading. // The X register is added (wrapping; discarding overflow) before loading.
@@ -123,7 +127,7 @@ func (c *Cpu) memoryAddress(in Instruction) uint16 {
case zeropageY: case zeropageY:
return uint16(in.Op8 + c.Y) return uint16(in.Op8 + c.Y)
default: default:
panic("unhandled addressing") panic(fmt.Errorf("Unhandled addressing mode: 0x%02X (%s). Are you sure your rom is compatible?", in.addressing, addressingNames[in.addressing]))
} }
} }