class CpuSetInstructionsTestCase(unittest.TestCase): def setUp(self): self.cpu = Cpu() def test_sec(self): instruction = self.cpu.decode(opcode=0x38) self.cpu.execute(instruction) self.assertTrue(self.cpu.p.c) def test_sed(self): instruction = self.cpu.decode(opcode=0xF8) self.cpu.execute(instruction) self.assertTrue(self.cpu.p.d) def test_sei(self): instruction = self.cpu.decode(opcode=0x78) self.cpu.execute(instruction) self.assertTrue(self.cpu.p.i)
def setUp(self): bus = Bus() bus.attach_device('RAM', Ram(256), 0, 256) self.cpu = Cpu(bus) self.cpu.write(0x0000, 0xff)
class CpuLoadInstructionsTestCase(unittest.TestCase): def setUp(self): bus = Bus() bus.attach_device('RAM', Ram(256), 0, 256) self.cpu = Cpu(bus) self.cpu.write(0x0000, 0xff) def test_lda(self): instruction = self.cpu.decode(0xAD) self.cpu.execute(instruction) self.assertEqual(self.cpu.a.value, 0xFF) self.assertFalse(self.cpu.p.z) self.assertTrue(self.cpu.p.n) def test_ldx(self): instruction = self.cpu.decode(0xAE) self.cpu.execute(instruction) self.assertEqual(self.cpu.x.value, 0xFF) self.assertFalse(self.cpu.p.z) self.assertTrue(self.cpu.p.n) def test_ldy(self): instruction = self.cpu.decode(0xAC) self.cpu.execute(instruction) self.assertEqual(self.cpu.y.value, 0xFF) self.assertFalse(self.cpu.p.z) self.assertTrue(self.cpu.p.n)
def setUp(self): bus = Bus() bus.attach_device('RAM', Ram(256), 0, 256) self.cpu = Cpu(bus)
class CpuDecrementInstructionsTestCase(unittest.TestCase): def setUp(self): bus = Bus() bus.attach_device('RAM', Ram(256), 0, 256) self.cpu = Cpu(bus) def test_dec(self): self.cpu.write(0x0000, 0x01) instruction = self.cpu.decode(0xCE) self.cpu.execute(instruction) self.assertEqual(self.cpu.read(0x0000), 0x00) self.assertTrue(self.cpu.p.z) self.assertFalse(self.cpu.p.n) def test_dex(self): self.cpu.x.value = 0x01 instruction = self.cpu.decode(0xCA) self.cpu.execute(instruction) self.assertEqual(self.cpu.x.value, 0x00) self.assertTrue(self.cpu.p.z) self.assertFalse(self.cpu.p.n) def test_dey(self): self.cpu.y.value = 0x01 instruction = self.cpu.decode(0x88) self.cpu.execute(instruction) self.assertEqual(self.cpu.y.value, 0x00) self.assertTrue(self.cpu.p.z) self.assertFalse(self.cpu.p.n)
def setUp(self): self.cpu = Cpu()
def setUp(self): bus = Bus() bus.attach_device('Stack Area', Ram(0x100), 0x100, 0x100) self.cpu = Cpu(bus)
class CpuTransferInstructionsTestCase(unittest.TestCase): def setUp(self): bus = Bus() bus.attach_device('Stack Area', Ram(0x100), 0x100, 0x100) self.cpu = Cpu(bus) def test_tax(self): self.cpu.a.value = 3 instruction = self.cpu.decode(0xAA) self.cpu.execute(instruction) self.assertEqual(self.cpu.a.value, self.cpu.x.value) self.assertEqual(self.cpu.x.value, 3) def test_tay(self): self.cpu.a.value = 2 instruction = self.cpu.decode(0xA8) self.cpu.execute(instruction) self.assertEqual(self.cpu.a.value, self.cpu.y.value) self.assertEqual(self.cpu.y.value, 2) def test_txa(self): self.cpu.x.value = 10 instruction = self.cpu.decode(0x8A) self.cpu.execute(instruction) self.assertEqual(self.cpu.a.value, self.cpu.x.value) self.assertEqual(self.cpu.a.value, 10) def test_tya(self): self.cpu.y.value = 0xDD instruction = self.cpu.decode(0x98) self.cpu.execute(instruction) self.assertEqual(self.cpu.a.value, self.cpu.y.value) self.assertEqual(self.cpu.a.value, 0xDD) def test_tsx(self): self.cpu.s.value = 0xFD instruction = self.cpu.decode(0xBA) self.cpu.execute(instruction) self.assertEqual(self.cpu.x.value, 0xFD) def test_txs(self): self.cpu.x.value = 0xAA instruction = self.cpu.decode(0x9A) self.cpu.execute(instruction) self.assertEqual(self.cpu.s.value, 0xAA)
class CpuStoreInstructionsTestCase(unittest.TestCase): def setUp(self): bus = Bus() bus.attach_device('RAM', Ram(256), 0, 256) self.cpu = Cpu(bus) self.cpu.write(0x0000, 0x00) def test_sta(self): self.cpu.a.value = 0xff instruction = self.cpu.decode(0x8D) instruction.parameter = 0x0000 self.cpu.execute(instruction) self.assertEqual(self.cpu.read(0x0000), 0xff) def test_stx(self): self.cpu.x.value = 0xff instruction = self.cpu.decode(0x8E) instruction.parameter = 0x0000 self.cpu.execute(instruction) self.assertEqual(self.cpu.read(0x0000), 0xff) def test_sty(self): self.cpu.y.value = 0xff instruction = self.cpu.decode(0x8C) instruction.parameter = 0x0000 self.cpu.execute(instruction) self.assertEqual(self.cpu.read(0x0000), 0xff)
class CpuClearInstructionsTestCase(unittest.TestCase): def setUp(self): self.cpu = Cpu() def test_clc(self): instruction = self.cpu.decode(opcode=0x18) self.cpu.execute(instruction) self.assertFalse(self.cpu.p.c) def test_cld(self): instruction = self.cpu.decode(opcode=0xD8) self.cpu.execute(instruction) self.assertFalse(self.cpu.p.d) def test_cli(self): instruction = self.cpu.decode(opcode=0x58) self.cpu.execute(instruction) self.assertFalse(self.cpu.p.i) def test_clv(self): instruction = self.cpu.decode(opcode=0xB8) self.cpu.execute(instruction) self.assertFalse(self.cpu.p.v)