From cba7990d29d5c2cafda1e9838fafa13b4efba602 Mon Sep 17 00:00:00 2001 From: Mike Naberezny Date: Sun, 12 Apr 2009 15:52:17 -0700 Subject: [PATCH] Added tests to assert RMBx instructions do not change SR. --- src/py65/tests/devices/test_mpu65c02.py | 72 +++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/py65/tests/devices/test_mpu65c02.py b/src/py65/tests/devices/test_mpu65c02.py index c79de34..d2b8536 100644 --- a/src/py65/tests/devices/test_mpu65c02.py +++ b/src/py65/tests/devices/test_mpu65c02.py @@ -355,6 +355,15 @@ class MPUTests(unittest.TestCase, Common6502Tests): expected = int('11111110', 2) self.assertEquals(expected, mpu.memory[0x0043]) + def test_rmb0_does_not_affect_status_register(self): + mpu = self._make_mpu() + mpu.memory[0x0043] = int('11111111',2) + self._write(mpu.memory, 0x0000, (0x07, 0x43)) #=> RMB0 $43 + expected = int('01010101', 2) + mpu.flags = expected + mpu.step() + self.assertEquals(expected, mpu.flags) + # RMB1 def test_rmb1_clears_bit_1_without_affecting_other_bits(self): @@ -367,6 +376,15 @@ class MPUTests(unittest.TestCase, Common6502Tests): expected = int('11111101', 2) self.assertEquals(expected, mpu.memory[0x0043]) + def test_rmb1_does_not_affect_status_register(self): + mpu = self._make_mpu() + mpu.memory[0x0043] = int('11111111',2) + self._write(mpu.memory, 0x0000, (0x17, 0x43)) #=> RMB1 $43 + expected = int('01010101', 2) + mpu.flags = expected + mpu.step() + self.assertEquals(expected, mpu.flags) + # RMB2 def test_rmb2_clears_bit_2_without_affecting_other_bits(self): @@ -379,6 +397,15 @@ class MPUTests(unittest.TestCase, Common6502Tests): expected = int('11111011', 2) self.assertEquals(expected, mpu.memory[0x0043]) + def test_rmb2_does_not_affect_status_register(self): + mpu = self._make_mpu() + mpu.memory[0x0043] = int('11111111',2) + self._write(mpu.memory, 0x0000, (0x27, 0x43)) #=> RMB2 $43 + expected = int('01010101', 2) + mpu.flags = expected + mpu.step() + self.assertEquals(expected, mpu.flags) + # RMB3 def test_rmb3_clears_bit_3_without_affecting_other_bits(self): @@ -391,6 +418,15 @@ class MPUTests(unittest.TestCase, Common6502Tests): expected = int('11110111', 2) self.assertEquals(expected, mpu.memory[0x0043]) + def test_rmb3_does_not_affect_status_register(self): + mpu = self._make_mpu() + mpu.memory[0x0043] = int('11111111',2) + self._write(mpu.memory, 0x0000, (0x37, 0x43)) #=> RMB3 $43 + expected = int('01010101', 2) + mpu.flags = expected + mpu.step() + self.assertEquals(expected, mpu.flags) + # RMB4 def test_rmb4_clears_bit_4_without_affecting_other_bits(self): @@ -403,6 +439,15 @@ class MPUTests(unittest.TestCase, Common6502Tests): expected = int('11101111', 2) self.assertEquals(expected, mpu.memory[0x0043]) + def test_rmb4_does_not_affect_status_register(self): + mpu = self._make_mpu() + mpu.memory[0x0043] = int('11111111',2) + self._write(mpu.memory, 0x0000, (0x47, 0x43)) #=> RMB4 $43 + expected = int('01010101', 2) + mpu.flags = expected + mpu.step() + self.assertEquals(expected, mpu.flags) + # RMB5 def test_rmb5_clears_bit_5_without_affecting_other_bits(self): @@ -415,6 +460,15 @@ class MPUTests(unittest.TestCase, Common6502Tests): expected = int('11011111', 2) self.assertEquals(expected, mpu.memory[0x0043]) + def test_rmb5_does_not_affect_status_register(self): + mpu = self._make_mpu() + mpu.memory[0x0043] = int('11111111',2) + self._write(mpu.memory, 0x0000, (0x57, 0x43)) #=> RMB5 $43 + expected = int('01010101', 2) + mpu.flags = expected + mpu.step() + self.assertEquals(expected, mpu.flags) + # RMB6 def test_rmb6_clears_bit_6_without_affecting_other_bits(self): @@ -427,6 +481,15 @@ class MPUTests(unittest.TestCase, Common6502Tests): expected = int('10111111', 2) self.assertEquals(expected, mpu.memory[0x0043]) + def test_rmb6_does_not_affect_status_register(self): + mpu = self._make_mpu() + mpu.memory[0x0043] = int('11111111',2) + self._write(mpu.memory, 0x0000, (0x67, 0x43)) #=> RMB6 $43 + expected = int('01010101', 2) + mpu.flags = expected + mpu.step() + self.assertEquals(expected, mpu.flags) + # RMB7 def test_rmb7_clears_bit_7_without_affecting_other_bits(self): @@ -439,6 +502,15 @@ class MPUTests(unittest.TestCase, Common6502Tests): expected = int('01111111', 2) self.assertEquals(expected, mpu.memory[0x0043]) + def test_rmb7_does_not_affect_status_register(self): + mpu = self._make_mpu() + mpu.memory[0x0043] = int('11111111',2) + self._write(mpu.memory, 0x0000, (0x77, 0x43)) #=> RMB7 $43 + expected = int('01010101', 2) + mpu.flags = expected + mpu.step() + self.assertEquals(expected, mpu.flags) + # STA Zero Page, Indirect def test_sta_zp_indirect_stores_a_leaves_a_and_n_flag_unchanged(self):