From 4bd92cf80ef94b131c1dbd5b6d51339a0e071eb8 Mon Sep 17 00:00:00 2001 From: Ed Spittles Date: Wed, 15 Dec 2010 20:20:17 +0000 Subject: [PATCH] two more BCD tests, presently failing according to Bruce Clark's test --- src/py65/tests/devices/test_mpu6502.py | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/py65/tests/devices/test_mpu6502.py b/src/py65/tests/devices/test_mpu6502.py index c31bc34..2c2958f 100644 --- a/src/py65/tests/devices/test_mpu6502.py +++ b/src/py65/tests/devices/test_mpu6502.py @@ -347,6 +347,20 @@ class Common6502Tests: self.assertEquals(0, mpu.p & mpu.ZERO) self.assertEquals(0, mpu.p & mpu.CARRY) + def test_adc_bcd_on_immediate_6f_plus_00_carry_set(self): + mpu = self._make_mpu() + mpu.p |= mpu.DECIMAL + mpu.p |= mpu.CARRY + mpu.a = 0x6f + self._write(mpu.memory, 0x0000, (0x69, 0x00)) #=> $0000 ADC #$00 + mpu.step() + self.assertEquals(0x0002, mpu.pc) + self.assertEquals(0x76, mpu.a) + self.assertEquals(0, mpu.p & mpu.NEGATIVE) + self.assertEquals(0, mpu.p & mpu.OVERFLOW) + self.assertEquals(0, mpu.p & mpu.ZERO) + self.assertEquals(0, mpu.p & mpu.CARRY) + # ADC Absolute, X-Indexed def test_adc_bcd_off_abs_x_carry_clear_in_accumulator_zeroes(self): @@ -4126,6 +4140,22 @@ class Common6502Tests: self.assertEquals(0, mpu.p & mpu.ZERO) self.assertEquals(mpu.CARRY, mpu.p & mpu.CARRY) + def test_sbc_bcd_on_immediate_00_minus_01_carry_set(self): + mpu = self._make_mpu() + mpu.p |= mpu.DECIMAL + mpu.p |= mpu.OVERFLOW + mpu.p |= mpu.ZERO + mpu.p |= mpu.CARRY + mpu.a = 0x00 + self._write(mpu.memory, 0x0000, (0xe9, 0x01)) #=> $0000 SBC #$00 + mpu.step() + self.assertEquals(0x0002, mpu.pc) + self.assertEquals(0x99, mpu.a) + self.assertEquals(mpu.NEGATIVE, mpu.p & mpu.NEGATIVE) + self.assertEquals(0, mpu.p & mpu.OVERFLOW) + self.assertEquals(0, mpu.p & mpu.ZERO) + self.assertEquals(0, mpu.p & mpu.CARRY) + # SBC Absolute, X-Indexed def test_sbc_abs_x_all_zeros_and_no_borrow_is_zero(self):