class TestJumpCallOperations(unittest.TestCase): def setUp(self): self.memory = Memory(use_bus=False) self.cpu = CPU(self.memory) def test_JMP(self): self.cpu.JMP(0x1000) self.assertEqual(self.cpu.program_counter, 0x1000) def test_JSR(self): self.cpu.program_counter = 0x1000 self.cpu.JSR(0x2000) self.assertEqual(self.cpu.program_counter, 0x2000) self.assertEqual( self.memory.read_byte( None, self.cpu.STACK_PAGE + self.cpu.stack_pointer + 1), 0xFF) self.assertEqual( self.memory.read_byte( None, self.cpu.STACK_PAGE + self.cpu.stack_pointer + 2), 0x0F) def test_RTS(self): self.memory.write_byte(None, self.cpu.STACK_PAGE + 0xFF, 0x12) self.memory.write_byte(None, self.cpu.STACK_PAGE + 0xFE, 0x33) self.cpu.stack_pointer = 0xFD self.cpu.RTS() self.assertEqual(self.cpu.program_counter, 0x1234) def test_JSR_and_RTS(self): self.cpu.program_counter = 0x1000 self.cpu.JSR(0x2000) self.assertEqual(self.cpu.program_counter, 0x2000) self.cpu.RTS() self.assertEqual(self.cpu.program_counter, 0x1000) # @@@