1
0
mirror of https://github.com/ariejan/i6502.git synced 2024-05-28 22:41:34 +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:
return in.Op16 + uint16(c.Y)
case indirect:
location := uint16(in.Op16)
return c.Bus.Read16(location)
// Indexed Indirect (X)
// Operand is the zero-page location of a little-endian 16-bit base address.
// The X register is added (wrapping; discarding overflow) before loading.
@ -123,7 +127,7 @@ func (c *Cpu) memoryAddress(in Instruction) uint16 {
case zeropageY:
return uint16(in.Op8 + c.Y)
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]))
}
}