diff --git a/src/py65/devices/mpu65c02.py b/src/py65/devices/mpu65c02.py index 6ef2e5c..7f4cda7 100644 --- a/src/py65/devices/mpu65c02.py +++ b/src/py65/devices/mpu65c02.py @@ -43,6 +43,11 @@ class MPU(NMOS6502): self.memory[address] = m & ~self.a # instructions + + @instruction(name="ORA", mode="zpi", cycles=5) + def i12(self): + self.opORA(self.IndirectXAddr) + self.pc += 1 @instruction(name="PHY", mode="imp", cycles=3) def i5a(self): diff --git a/src/py65/tests/devices/test_mpu65c02.py b/src/py65/tests/devices/test_mpu65c02.py index 9138aab..16dea3f 100644 --- a/src/py65/tests/devices/test_mpu65c02.py +++ b/src/py65/tests/devices/test_mpu65c02.py @@ -38,6 +38,33 @@ class MPUTests(unittest.TestCase, Common6502Tests): self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO) self.assertEquals(0, mpu.flags & mpu.NEGATIVE) + # ORA Zero Page, Indirect + + def test_ora_zp_indirect_x_zeroes_or_zeros_sets_z_flag(self): + mpu = self._make_mpu() + mpu.flags &= ~(mpu.ZERO) + mpu.a = 0x00 + self._write(mpu.memory, 0x0000, (0x12, 0x10)) #=> ORA ($0010) + self._write(mpu.memory, 0x0010, (0xCD, 0xAB)) #=> Vector to $ABCD + mpu.memory[0xABCD] = 0x00 + mpu.step() + self.assertEquals(0x0002, mpu.pc) + self.assertEquals(0x00, mpu.a) + self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO) + + def test_ora_zp_indirect_x_turns_bits_on_sets_n_flag(self): + mpu = self._make_mpu() + mpu.flags &= ~(mpu.NEGATIVE) + mpu.a = 0x03 + self._write(mpu.memory, 0x0000, (0x12, 0x10)) #=> ORA ($0010) + self._write(mpu.memory, 0x0010, (0xCD, 0xAB)) #=> Vector to $ABCD + mpu.memory[0xABCD] = 0x82 + mpu.step() + self.assertEquals(0x0002, mpu.pc) + self.assertEquals(0x83, mpu.a) + self.assertEquals(mpu.NEGATIVE, mpu.flags & mpu.NEGATIVE) + self.assertEquals(0, mpu.flags & mpu.ZERO) + # PHX def test_phx_pushes_x_and_updates_sp(self):