diff --git a/src/py65/tests/devices/test_mpu6502.py b/src/py65/tests/devices/test_mpu6502.py index 997a116..f067445 100644 --- a/src/py65/tests/devices/test_mpu6502.py +++ b/src/py65/tests/devices/test_mpu6502.py @@ -361,6 +361,24 @@ class Common6502Tests: self.assertEqual(0, mpu.p & mpu.ZERO) self.assertEqual(0, mpu.p & mpu.CARRY) + def test_adc_bcd_on_immediate_9c_plus_9d(self): + mpu = self._make_mpu() + mpu.p |= mpu.DECIMAL + mpu.p &= ~(mpu.CARRY) + mpu.a = 0x9c + self._write(mpu.memory, 0x0000, (0x69, 0x9d)) #=> $0000 ADC #$9d + self._write(mpu.memory, 0x0002, (0x69, 0x9d)) #=> $0000 ADC #$9d + mpu.step() + self.assertEqual(0x9f, mpu.a) + self.assertEqual(mpu.CARRY, mpu.p & mpu.CARRY) + mpu.step() + self.assertEqual(0x0004, mpu.pc) + self.assertEqual(0x93, mpu.a) + self.assertEqual(0, mpu.p & mpu.NEGATIVE) + self.assertEqual(mpu.OVERFLOW, mpu.p & mpu.OVERFLOW) + self.assertEqual(0, mpu.p & mpu.ZERO) + self.assertEqual(mpu.CARRY, mpu.p & mpu.CARRY) + # ADC Absolute, X-Indexed def test_adc_bcd_off_abs_x_carry_clear_in_accumulator_zeroes(self): @@ -4156,6 +4174,19 @@ class Common6502Tests: self.assertEqual(0, mpu.p & mpu.ZERO) self.assertEqual(0, mpu.p & mpu.CARRY) + def test_sbc_bcd_on_immediate_20_minus_0a_carry_unset(self): + mpu = self._make_mpu() + mpu.p |= mpu.DECIMAL + mpu.a = 0x20 + self._write(mpu.memory, 0x0000, (0xe9, 0x0a)) #=> $0000 SBC #$00 + mpu.step() + self.assertEqual(0x0002, mpu.pc) + self.assertEqual(0x1f, mpu.a) + self.assertEqual(0, mpu.p & mpu.NEGATIVE) + self.assertEqual(0, mpu.p & mpu.OVERFLOW) + self.assertEqual(0, mpu.p & mpu.ZERO) + self.assertEqual(mpu.CARRY, mpu.p & mpu.CARRY) + # SBC Absolute, X-Indexed def test_sbc_abs_x_all_zeros_and_no_borrow_is_zero(self):