mirror of
https://github.com/mnaberez/py65.git
synced 2025-04-06 20:37:18 +00:00
add 3 (failing) BCD tests and comment a weak spot in opSBC
This commit is contained in:
parent
f7c7d97a96
commit
b234ac4c32
@ -375,7 +375,7 @@ class MPU:
|
||||
else:
|
||||
self.p |= self.NEGATIVE
|
||||
data +=100
|
||||
self.a = convert_to_bcd(data)
|
||||
self.a = convert_to_bcd(data) # throws exception if result is over 99 decimal
|
||||
else:
|
||||
if self.p & self.CARRY:
|
||||
borrow = 0
|
||||
|
@ -333,6 +333,20 @@ class Common6502Tests:
|
||||
self.assertEquals(mpu.OVERFLOW, mpu.p & mpu.OVERFLOW)
|
||||
self.assertEquals(0, mpu.p & mpu.ZERO)
|
||||
|
||||
def test_adc_bcd_on_immediate_79_plus_00_carry_set(self):
|
||||
mpu = self._make_mpu()
|
||||
mpu.p |= mpu.DECIMAL
|
||||
mpu.p |= mpu.CARRY
|
||||
mpu.a = 0x79
|
||||
self._write(mpu.memory, 0x0000, (0x69, 0x00)) #=> $0000 ADC #$00
|
||||
mpu.step()
|
||||
self.assertEquals(0x0002, mpu.pc)
|
||||
self.assertEquals(0x80, mpu.a)
|
||||
self.assertEquals(mpu.NEGATIVE, mpu.p & mpu.NEGATIVE)
|
||||
self.assertEquals(mpu.OVERFLOW, 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):
|
||||
@ -4084,6 +4098,34 @@ class Common6502Tests:
|
||||
self.assertEquals(0, mpu.p & mpu.ZERO)
|
||||
self.assertEquals(mpu.CARRY, mpu.CARRY)
|
||||
|
||||
def test_sbc_bcd_on_immediate_0a_minus_00_carry_set(self):
|
||||
mpu = self._make_mpu()
|
||||
mpu.p |= mpu.DECIMAL
|
||||
mpu.p |= mpu.CARRY
|
||||
mpu.a = 0x0a
|
||||
self._write(mpu.memory, 0x0000, (0xe9, 0x00)) #=> $0000 SBC #$00
|
||||
mpu.step()
|
||||
self.assertEquals(0x0002, mpu.pc)
|
||||
self.assertEquals(0x0a, 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(mpu.CARRY, mpu.p & mpu.CARRY)
|
||||
|
||||
def test_sbc_bcd_on_immediate_9a_minus_00_carry_set(self):
|
||||
mpu = self._make_mpu()
|
||||
mpu.p |= mpu.DECIMAL
|
||||
mpu.p |= mpu.CARRY
|
||||
mpu.a = 0x9a
|
||||
self._write(mpu.memory, 0x0000, (0xe9, 0x00)) #=> $0000 SBC #$00
|
||||
mpu.step()
|
||||
self.assertEquals(0x0002, mpu.pc)
|
||||
self.assertEquals(0x9a, 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(mpu.CARRY, mpu.p & mpu.CARRY)
|
||||
|
||||
# SBC Absolute, X-Indexed
|
||||
|
||||
def test_sbc_abs_x_all_zeros_and_no_borrow_is_zero(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user