1
0
mirror of https://github.com/mnaberez/py65.git synced 2024-11-18 15:06:35 +00:00

Processor status (p) is now "p" instead of "flags".

This commit is contained in:
Mike Naberezny 2009-08-21 19:30:12 -07:00
parent 6b61cdf5b3
commit af3fc635ff
4 changed files with 1140 additions and 1140 deletions

View File

@ -36,7 +36,7 @@ class MPU:
self.reset()
def __repr__(self):
flags = itoa(self.flags, 2).rjust(8, '0')
flags = itoa(self.p, 2).rjust(8, '0')
indent = ' ' * (len(self.name) + 2)
out = "%s PC AC XR YR SP NV-BDIZC\n" + \
@ -62,7 +62,7 @@ class MPU:
self.a = 0
self.x = 0
self.y = 0
self.flags = 0
self.p = 0
self.processorCycles = 0
# Helpers for addressing modes
@ -163,11 +163,11 @@ class MPU:
return z
def FlagsNZ(self, value):
self.flags &= ~(self.ZERO + self.NEGATIVE)
self.p &= ~(self.ZERO + self.NEGATIVE)
if value == 0:
self.flags |= self.ZERO
self.p |= self.ZERO
else:
self.flags |= value & self.NEGATIVE
self.p |= value & self.NEGATIVE
# operations
@ -182,16 +182,16 @@ class MPU:
addr = x()
tbyte = self.ByteAt(addr)
self.flags &= ~(self.CARRY + self.NEGATIVE + self.ZERO)
self.p &= ~(self.CARRY + self.NEGATIVE + self.ZERO)
if tbyte & 128:
self.flags |= self.CARRY
self.p |= self.CARRY
tbyte = (tbyte << 1) & 0xFF
if tbyte:
self.flags |= tbyte & 128
self.p |= tbyte & 128
else:
self.flags |= self.ZERO
self.p |= self.ZERO
if x is None:
self.a = tbyte
@ -205,14 +205,14 @@ class MPU:
addr = x()
tbyte = self.ByteAt(addr)
self.flags &=~(self.CARRY+self.NEGATIVE+self.ZERO)
self.flags |=tbyte&1
self.p &=~(self.CARRY+self.NEGATIVE+self.ZERO)
self.p |=tbyte&1
tbyte = tbyte >> 1
if tbyte:
pass # {}
else:
self.flags |= self.ZERO
self.p |= self.ZERO
if x is None:
self.a = tbyte
@ -220,22 +220,22 @@ class MPU:
self.memory[addr]=tbyte
def opBCL(self, x):
if self.flags & x:
if self.p & x:
self.pc += 1
else:
self.BranchRelAddr()
def opBST(self, x):
if self.flags & x:
if self.p & x:
self.BranchRelAddr()
else:
self.pc += 1
def opCLR(self, x):
self.flags &=~x
self.p &=~x
def opSET(self, x):
self.flags |= x
self.p |= x
def opAND(self, x):
self.a &= self.ByteAt(x())
@ -243,10 +243,10 @@ class MPU:
def opBIT(self, x):
tbyte = self.ByteAt(x())
self.flags &=~(self.ZERO+self.NEGATIVE+self.OVERFLOW)
self.p &=~(self.ZERO+self.NEGATIVE+self.OVERFLOW)
if (self.a & tbyte) == 0:
self.flags |= self.ZERO
self.flags |= tbyte&(128+64)
self.p |= self.ZERO
self.p |= tbyte&(128+64)
def opROL(self, x):
if x is None:
@ -255,15 +255,15 @@ class MPU:
addr = x()
tbyte = self.ByteAt(addr)
if self.flags & self.CARRY:
if self.p & self.CARRY:
if tbyte & 128:
pass
else:
self.flags &= ~self.CARRY
self.p &= ~self.CARRY
tbyte = (tbyte << 1) | 1
else:
if tbyte & 128:
self.flags |= self.CARRY
self.p |= self.CARRY
tbyte = tbyte << 1
tbyte &= 0xFF
self.FlagsNZ(tbyte)
@ -280,39 +280,39 @@ class MPU:
def opADC(self, x):
data = self.ByteAt(x())
if self.flags & self.DECIMAL:
if self.flags & self.CARRY:
if self.p & self.DECIMAL:
if self.p & self.CARRY:
tmp = 1
else:
tmp = 0
data = convert_to_bin(data) + convert_to_bin(self.a) + tmp
self.flags &= ~(self.CARRY+self.OVERFLOW+self.NEGATIVE+self.ZERO)
self.p &= ~(self.CARRY+self.OVERFLOW+self.NEGATIVE+self.ZERO)
if data > 99:
self.flags |= self.CARRY + self.OVERFLOW
self.p |= self.CARRY + self.OVERFLOW
data -= 100
if data == 0:
self.flags |= self.ZERO
self.p |= self.ZERO
else:
self.flags |= data & 128
self.p |= data & 128
self.a = convert_to_bcd(data)
else:
if self.flags & self.CARRY:
if self.p & self.CARRY:
tmp = 1
else:
tmp = 0
result = data + self.a + tmp
self.flags &= ~(self.CARRY+self.OVERFLOW+self.NEGATIVE+self.ZERO)
self.p &= ~(self.CARRY+self.OVERFLOW+self.NEGATIVE+self.ZERO)
if ( ~(self.a ^ data) & (self.a ^ result) ) & 0x80:
self.flags |= self.OVERFLOW
self.p |= self.OVERFLOW
data = result
if data > 255:
self.flags |= self.CARRY
self.p |= self.CARRY
data &=255
if data == 0:
self.flags |= self.ZERO
self.p |= self.ZERO
else:
self.flags |= data & 128
self.p |= data & 128
self.a = data
def opROR(self, x):
@ -322,15 +322,15 @@ class MPU:
addr=x()
tbyte = self.ByteAt(addr)
if self.flags & self.CARRY:
if self.p & self.CARRY:
if tbyte & 1:
pass # {}
else:
self.flags &=~ self.CARRY
self.p &=~ self.CARRY
tbyte=(tbyte>>1)|128
else:
if tbyte & 1:
self.flags |= self.CARRY
self.p |= self.CARRY
tbyte=tbyte>>1
self.FlagsNZ(tbyte)
@ -350,48 +350,48 @@ class MPU:
def opCMPR(self, get_address, register_value):
tbyte = self.ByteAt(get_address())
self.flags &= ~(self.CARRY+self.ZERO+self.NEGATIVE)
self.p &= ~(self.CARRY+self.ZERO+self.NEGATIVE)
if register_value == tbyte:
self.flags |= self.CARRY + self.ZERO
self.p |= self.CARRY + self.ZERO
elif register_value > tbyte:
self.flags |= self.CARRY
self.flags |= (register_value - tbyte) & self.NEGATIVE
self.p |= self.CARRY
self.p |= (register_value - tbyte) & self.NEGATIVE
def opSBC(self, x):
data = self.ByteAt(x())
if self.flags & self.DECIMAL:
if self.flags & self.CARRY:
if self.p & self.DECIMAL:
if self.p & self.CARRY:
borrow = 0
else:
borrow = 1
data = convert_to_bin(self.a) - convert_to_bin(data) - borrow
self.flags &= ~(self.CARRY + self.ZERO + self.NEGATIVE + self.OVERFLOW)
self.p &= ~(self.CARRY + self.ZERO + self.NEGATIVE + self.OVERFLOW)
if data == 0:
self.flags |= self.ZERO + self.CARRY
self.p |= self.ZERO + self.CARRY
elif data > 0:
self.flags |= self.CARRY
self.p |= self.CARRY
else:
self.flags |= self.NEGATIVE
self.p |= self.NEGATIVE
data +=100
self.a = convert_to_bcd(data)
else:
if self.flags & self.CARRY:
if self.p & self.CARRY:
borrow = 0
else:
borrow = 1
result = self.a - data - borrow
self.flags &= ~(self.CARRY + self.ZERO + self.OVERFLOW + self.NEGATIVE)
self.p &= ~(self.CARRY + self.ZERO + self.OVERFLOW + self.NEGATIVE)
if ( (self.a ^ data) & (self.a ^ result) ) & 0x80:
self.flags |= self.OVERFLOW
self.p |= self.OVERFLOW
data = result
if data == 0:
self.flags |= self.ZERO + self.CARRY
self.p |= self.ZERO + self.CARRY
elif data > 0:
self.flags |= self.CARRY
self.flags |= data & self.NEGATIVE
self.p |= self.CARRY
self.p |= data & self.NEGATIVE
self.a = data & 0xFF
def opDECR(self, x):
@ -401,12 +401,12 @@ class MPU:
addr = x()
tbyte = self.ByteAt(addr)
self.flags &= ~(self.ZERO + self.NEGATIVE)
self.p &= ~(self.ZERO + self.NEGATIVE)
tbyte = (tbyte - 1) & 0xFF
if tbyte:
self.flags |= tbyte & self.NEGATIVE
self.p |= tbyte & self.NEGATIVE
else:
self.flags |= self.ZERO
self.p |= self.ZERO
if x is None:
self.a = tbyte
@ -420,12 +420,12 @@ class MPU:
addr = x()
tbyte = self.ByteAt(addr)
self.flags &= ~(self.ZERO + self.NEGATIVE)
self.p &= ~(self.ZERO + self.NEGATIVE)
tbyte = (tbyte + 1) & 0xFF
if tbyte:
self.flags |= tbyte & self.NEGATIVE
self.p |= tbyte & self.NEGATIVE
else:
self.flags |= self.ZERO
self.p |= self.ZERO
if x is None:
self.a = tbyte
@ -464,10 +464,10 @@ class MPU:
pc = (self.pc + 1) & 0xFFFF # The pc has already been increased one
self.stPushWord(pc)
self.flags |= self.BREAK
self.stPush(self.flags)
self.p |= self.BREAK
self.stPush(self.p)
self.flags |= self.INTERRUPT
self.p |= self.INTERRUPT
self.pc = self.WordAt(self.IrqTo)
@instruction(name="ORA", mode="inx", cycles=6)
@ -487,7 +487,7 @@ class MPU:
@instruction(name="PHP", mode="imp", cycles=3)
def inst_0x08(self):
self.stPush(self.flags)
self.stPush(self.p)
@instruction(name="ORA", mode="imm", cycles=2)
def inst_0x09(self):
@ -573,7 +573,7 @@ class MPU:
@instruction(name="PLP", mode="imp", cycles=4)
def inst_0x28(self):
self.flags = self.stPop()
self.p = self.stPop()
@instruction(name="AND", mode="imm", cycles=2)
def inst_0x29(self):
@ -639,7 +639,7 @@ class MPU:
@instruction(name="RTI", mode="imp", cycles=6)
def inst_0x40(self):
self.flags = self.stPop()
self.p = self.stPop()
self.pc = self.stPopWord()
@instruction(name="EOR", mode="inx", cycles=6)

View File

@ -47,19 +47,19 @@ class MPU(mpu6502.MPU):
def opTSB(self, x):
address = x()
m = self.memory[address]
self.flags &= ~self.ZERO
self.p &= ~self.ZERO
z = m & self.a
if z != 0:
self.flags |= self.ZERO
self.p |= self.ZERO
self.memory[address] = m | self.a
def opTRB(self, x):
address = x()
m = self.memory[address]
self.flags &= ~self.ZERO
self.p &= ~self.ZERO
z = m & self.a
if z != 0:
self.flags |= self.ZERO
self.p |= self.ZERO
self.memory[address] = m & ~self.a
# instructions

File diff suppressed because it is too large Load Diff

View File

@ -23,14 +23,14 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x00, mpu.a)
self.assertEquals(0, mpu.flags & mpu.CARRY)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(0, mpu.p & mpu.CARRY)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
def test_adc_bcd_off_zp_indirect_carry_set_in_accumulator_zero(self):
mpu = self._make_mpu()
mpu.a = 0
mpu.flags |= mpu.CARRY
mpu.p |= mpu.CARRY
self._write(mpu.memory, 0x0000, (0x72, 0x10)) #=> $0000 ADC ($0010)
self._write(mpu.memory, 0x0010, (0xCD, 0xAB)) #=> Vector to $ABCD
mpu.memory[0xABCD] = 0x00
@ -38,9 +38,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x01, mpu.a)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertNotEquals(mpu.CARRY, mpu.flags & mpu.CARRY)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.ZERO)
self.assertNotEquals(mpu.CARRY, mpu.p & mpu.CARRY)
def test_adc_bcd_off_zp_indirect_carry_clear_in_no_carry_clear_out(self):
mpu = self._make_mpu()
@ -52,9 +52,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0xFF, mpu.a)
self.assertEquals(mpu.NEGATIVE, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.flags & mpu.CARRY)
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.NEGATIVE, mpu.p & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.CARRY)
self.assertEquals(0, mpu.p & mpu.ZERO)
def test_adc_bcd_off_zp_indirect_carry_clear_in_carry_set_out(self):
mpu = self._make_mpu()
@ -66,13 +66,13 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x01, mpu.a)
self.assertEquals(mpu.CARRY, mpu.flags & mpu.CARRY)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.CARRY, mpu.p & mpu.CARRY)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.ZERO)
def test_adc_bcd_off_zp_indirect_overflow_cleared_no_carry_01_plus_01(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.CARRY)
mpu.p &= ~(mpu.CARRY)
mpu.a = 0x01
self._write(mpu.memory, 0x0000, (0x72, 0x10)) #=> $0000 ADC ($0010)
self._write(mpu.memory, 0x0010, (0xCD, 0xAB)) #=> Vector to $ABCD
@ -80,11 +80,11 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.step()
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(0x02, mpu.a)
self.assertEquals(0, mpu.flags & mpu.OVERFLOW)
self.assertEquals(0, mpu.p & mpu.OVERFLOW)
def test_adc_bcd_off_zp_indirect_overflow_cleared_no_carry_01_plus_ff(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.CARRY)
mpu.p &= ~(mpu.CARRY)
mpu.a = 0x01
self._write(mpu.memory, 0x0000, (0x72, 0x10)) #=> $0000 ADC ($0010)
self._write(mpu.memory, 0x0010, (0xCD, 0xAB)) #=> Vector to $ABCD
@ -92,11 +92,11 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.step()
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(0x00, mpu.a)
self.assertEquals(0, mpu.flags & mpu.OVERFLOW)
self.assertEquals(0, mpu.p & mpu.OVERFLOW)
def test_adc_bcd_off_zp_indirect_overflow_set_no_carry_7f_plus_01(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.CARRY)
mpu.p &= ~(mpu.CARRY)
mpu.a = 0x7f
self._write(mpu.memory, 0x0000, (0x72, 0x10)) #=> $0000 ADC ($0010)
self._write(mpu.memory, 0x0010, (0xCD, 0xAB)) #=> Vector to $ABCD
@ -104,11 +104,11 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.step()
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(0x80, mpu.a)
self.assertEquals(mpu.OVERFLOW, mpu.flags & mpu.OVERFLOW)
self.assertEquals(mpu.OVERFLOW, mpu.p & mpu.OVERFLOW)
def test_adc_bcd_off_zp_indirect_overflow_set_no_carry_80_plus_ff(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.CARRY)
mpu.p &= ~(mpu.CARRY)
mpu.a = 0x80
self._write(mpu.memory, 0x0000, (0x72, 0x10)) #=> $0000 ADC ($0010)
self._write(mpu.memory, 0x0010, (0xCD, 0xAB)) #=> Vector to $ABCD
@ -116,7 +116,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.step()
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(0x7f, mpu.a)
self.assertEquals(mpu.OVERFLOW, mpu.flags & mpu.OVERFLOW)
self.assertEquals(mpu.OVERFLOW, mpu.p & mpu.OVERFLOW)
def test_adc_bcd_off_zp_indirect_overflow_set_on_40_plus_40(self):
mpu = self._make_mpu()
@ -127,9 +127,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.step()
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(0x80, mpu.a)
self.assertEquals(mpu.NEGATIVE, mpu.flags & mpu.NEGATIVE)
self.assertEquals(mpu.OVERFLOW, mpu.flags & mpu.OVERFLOW)
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.NEGATIVE, mpu.p & mpu.NEGATIVE)
self.assertEquals(mpu.OVERFLOW, mpu.p & mpu.OVERFLOW)
self.assertEquals(0, mpu.p & mpu.ZERO)
# AND Zero Page, Indirect
@ -143,8 +143,8 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x00, mpu.a)
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
def test_and_zp_indirect_zeros_and_ones_setting_negative_flag(self):
mpu = self._make_mpu()
@ -156,68 +156,68 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0xAA, mpu.a)
self.assertEquals(mpu.NEGATIVE, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.NEGATIVE, mpu.p & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.ZERO)
# BIT (Absolute, X-Indexed)
def test_bit_abs_x_copies_bit_7_of_memory_to_n_flag_when_0(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.NEGATIVE)
mpu.p &= ~(mpu.NEGATIVE)
mpu.x = 0x02
self._write(mpu.memory, 0x0000, (0x3C, 0xEB, 0xFE)) #=> BIT $FEEB,X
mpu.memory[0xFEED] = 0xFF
mpu.a = 0xFF
mpu.step()
self.assertEquals(mpu.NEGATIVE, mpu.flags & mpu.NEGATIVE)
self.assertEquals(mpu.NEGATIVE, mpu.p & mpu.NEGATIVE)
self.assertEquals(4, mpu.processorCycles)
self.assertEquals(0x0003, mpu.pc)
def test_bit_abs_x_copies_bit_7_of_memory_to_n_flag_when_1(self):
mpu = self._make_mpu()
mpu.flags &= mpu.NEGATIVE
mpu.p &= mpu.NEGATIVE
mpu.x = 0x02
self._write(mpu.memory, 0x0000, (0x3C, 0xEB, 0xFE)) #=> BIT $FEEB,X
mpu.memory[0xFEED] = 0x00
mpu.a = 0xFF
mpu.step()
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
self.assertEquals(4, mpu.processorCycles)
self.assertEquals(0x0003, mpu.pc)
def test_bit_abs_x_copies_bit_6_of_memory_to_v_flag_when_0(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.OVERFLOW)
mpu.p &= ~(mpu.OVERFLOW)
mpu.x = 0x02
self._write(mpu.memory, 0x0000, (0x3C, 0xEB, 0xFE)) #=> BIT $FEEB,X
mpu.memory[0xFEED] = 0xFF
mpu.a = 0xFF
mpu.step()
self.assertEquals(mpu.OVERFLOW, mpu.flags & mpu.OVERFLOW)
self.assertEquals(mpu.OVERFLOW, mpu.p & mpu.OVERFLOW)
self.assertEquals(4, mpu.processorCycles)
self.assertEquals(0x0003, mpu.pc)
def test_bit_abs_x_copies_bit_6_of_memory_to_v_flag_when_1(self):
mpu = self._make_mpu()
mpu.flags &= mpu.OVERFLOW
mpu.p &= mpu.OVERFLOW
mpu.x = 0x02
self._write(mpu.memory, 0x0000, (0x3C, 0xEB, 0xFE)) #=> BIT $FEEB,X
mpu.memory[0xFEED] = 0x00
mpu.a = 0xFF
mpu.step()
self.assertEquals(0, mpu.flags & mpu.OVERFLOW)
self.assertEquals(0, mpu.p & mpu.OVERFLOW)
self.assertEquals(4, mpu.processorCycles)
self.assertEquals(0x0003, mpu.pc)
def test_bit_abs_x_stores_result_of_and_in_z_while_preserving_a_when_1(self):
mpu = self._make_mpu()
mpu.flags &= mpu.ZERO
mpu.p &= mpu.ZERO
mpu.x = 0x02
self._write(mpu.memory, 0x0000, (0x3C, 0xEB, 0xFE)) #=> BIT $FEEB,X
mpu.memory[0xFEED] = 0x00
mpu.a = 0x01
mpu.step()
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
self.assertEquals(0x01, mpu.a)
self.assertEquals(0x00, mpu.memory[0xFEED])
self.assertEquals(4, mpu.processorCycles)
@ -225,13 +225,13 @@ class MPUTests(unittest.TestCase, Common6502Tests):
def test_bit_abs_x_stores_result_of_and_when_nonzero_in_z_while_preserving_a(self):
mpu = self._make_mpu()
mpu.flags &= mpu.ZERO
mpu.p &= mpu.ZERO
mpu.x = 0x02
self._write(mpu.memory, 0x0000, (0x3C, 0xEB, 0xFE)) #=> BIT $FEEB,X
mpu.memory[0xFEED] = 0x01
mpu.a = 0x01
mpu.step()
self.assertEquals(0, mpu.flags & mpu.ZERO) # result of AND is non-zero
self.assertEquals(0, mpu.p & mpu.ZERO) # result of AND is non-zero
self.assertEquals(0x01, mpu.a)
self.assertEquals(0x01, mpu.memory[0xFEED])
self.assertEquals(4, mpu.processorCycles)
@ -239,13 +239,13 @@ class MPUTests(unittest.TestCase, Common6502Tests):
def test_bit_abs_x_stores_result_of_and_when_zero_in_z_while_preserving_a(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.ZERO)
mpu.p &= ~(mpu.ZERO)
mpu.x = 0x02
self._write(mpu.memory, 0x0000, (0x3C, 0xEB, 0xFE)) #=> BIT $FEEB,X
mpu.memory[0xFEED] = 0x00
mpu.a = 0x01
mpu.step()
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO) # result of AND is zero
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO) # result of AND is zero
self.assertEquals(0x01, mpu.a)
self.assertEquals(0x00, mpu.memory[0xFEED])
self.assertEquals(4, mpu.processorCycles)
@ -255,7 +255,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
def test_bit_zp_x_copies_bit_7_of_memory_to_n_flag_when_0(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.NEGATIVE)
mpu.p &= ~(mpu.NEGATIVE)
self._write(mpu.memory, 0x0000, (0x34, 0x10)) #=> BIT $0010,X
mpu.memory[0x0013] = 0xFF
mpu.x = 0x03
@ -263,11 +263,11 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.step()
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(4, mpu.processorCycles)
self.assertEquals(mpu.NEGATIVE, mpu.flags & mpu.NEGATIVE)
self.assertEquals(mpu.NEGATIVE, mpu.p & mpu.NEGATIVE)
def test_bit_zp_x_copies_bit_7_of_memory_to_n_flag_when_1(self):
mpu = self._make_mpu()
mpu.flags &= mpu.NEGATIVE
mpu.p &= mpu.NEGATIVE
self._write(mpu.memory, 0x0000, (0x34, 0x10)) #=> BIT $0010,X
mpu.memory[0x0013] = 0x00
mpu.x = 0x03
@ -275,11 +275,11 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.step()
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(4, mpu.processorCycles)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
def test_bit_zp_x_copies_bit_6_of_memory_to_v_flag_when_0(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.OVERFLOW)
mpu.p &= ~(mpu.OVERFLOW)
self._write(mpu.memory, 0x0000, (0x34, 0x10)) #=> BIT $0010,X
mpu.memory[0x0013] = 0xFF
mpu.x = 0x03
@ -287,11 +287,11 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.step()
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(4, mpu.processorCycles)
self.assertEquals(mpu.OVERFLOW, mpu.flags & mpu.OVERFLOW)
self.assertEquals(mpu.OVERFLOW, mpu.p & mpu.OVERFLOW)
def test_bit_zp_x_copies_bit_6_of_memory_to_v_flag_when_1(self):
mpu = self._make_mpu()
mpu.flags &= mpu.OVERFLOW
mpu.p &= mpu.OVERFLOW
self._write(mpu.memory, 0x0000, (0x34, 0x10)) #=> BIT $0010,X
mpu.memory[0x0013] = 0x00
mpu.x = 0x03
@ -299,17 +299,17 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.step()
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(4, mpu.processorCycles)
self.assertEquals(0, mpu.flags & mpu.OVERFLOW)
self.assertEquals(0, mpu.p & mpu.OVERFLOW)
def test_bit_zp_x_stores_result_of_and_in_z_while_preserving_a_when_1(self):
mpu = self._make_mpu()
mpu.flags &= mpu.ZERO
mpu.p &= mpu.ZERO
self._write(mpu.memory, 0x0000, (0x34, 0x10)) #=> BIT $0010,X
mpu.memory[0x0013] = 0x00
mpu.x = 0x03
mpu.a = 0x01
mpu.step()
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(4, mpu.processorCycles)
self.assertEquals(0x01, mpu.a)
@ -317,13 +317,13 @@ class MPUTests(unittest.TestCase, Common6502Tests):
def test_bit_zp_x_stores_result_of_and_when_nonzero_in_z_while_preserving_a(self):
mpu = self._make_mpu()
mpu.flags &= mpu.ZERO
mpu.p &= mpu.ZERO
self._write(mpu.memory, 0x0000, (0x34, 0x10)) #=> BIT $0010,X
mpu.memory[0x0013] = 0x01
mpu.x = 0x03
mpu.a = 0x01
mpu.step()
self.assertEquals(0, mpu.flags & mpu.ZERO) # result of AND is non-zero
self.assertEquals(0, mpu.p & mpu.ZERO) # result of AND is non-zero
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(4, mpu.processorCycles)
self.assertEquals(0x01, mpu.a)
@ -331,7 +331,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
def test_bit_zp_x_stores_result_of_and_when_zero_in_z_while_preserving_a(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.ZERO)
mpu.p &= ~(mpu.ZERO)
self._write(mpu.memory, 0x0000, (0x34, 0x10)) #=> BIT $0010,X
mpu.memory[0x0013] = 0x00
mpu.x = 0x03
@ -339,7 +339,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.step()
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(4, mpu.processorCycles)
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO) # result of AND is zero
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO) # result of AND is zero
self.assertEquals(0x01, mpu.a)
self.assertEquals(0x00, mpu.memory[0x0010 + mpu.x])
@ -356,7 +356,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x00, mpu.a)
self.assertEquals(0xFF, mpu.memory[0xABCD])
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
def test_eor_zp_indirect_flips_bits_over_setting_n_flag(self):
mpu = self._make_mpu()
@ -369,8 +369,8 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0xFF, mpu.a)
self.assertEquals(0xFF, mpu.memory[0xABCD])
self.assertEquals(mpu.NEGATIVE, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.NEGATIVE, mpu.p & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.ZERO)
# LDA Zero Page, Indirect
@ -384,8 +384,8 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x80, mpu.a)
self.assertEquals(mpu.NEGATIVE, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.NEGATIVE, mpu.p & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.ZERO)
def test_lda_zp_indirect_loads_a_sets_z_flag(self):
mpu = self._make_mpu()
@ -397,14 +397,14 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x00, mpu.a)
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
# ORA Zero Page, Indirect
def test_ora_zp_indirect_zeroes_or_zeros_sets_z_flag(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.ZERO)
mpu.p &= ~(mpu.ZERO)
mpu.a = 0x00
mpu.y = 0x12 # These should not affect the ORA
mpu.x = 0x34
@ -415,11 +415,11 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x00, mpu.a)
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
def test_ora_zp_indirect_turns_bits_on_sets_n_flag(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.NEGATIVE)
mpu.p &= ~(mpu.NEGATIVE)
mpu.a = 0x03
self._write(mpu.memory, 0x0000, (0x12, 0x10)) #=> ORA ($0010)
self._write(mpu.memory, 0x0010, (0xCD, 0xAB)) #=> Vector to $ABCD
@ -428,8 +428,8 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x83, mpu.a)
self.assertEquals(mpu.NEGATIVE, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.NEGATIVE, mpu.p & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.ZERO)
# PHX
@ -500,9 +500,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('11111111',2)
self._write(mpu.memory, 0x0000, (0x07, 0x43)) #=> RMB0 $43
expected = int('01010101', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# RMB1
@ -521,9 +521,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('11111111',2)
self._write(mpu.memory, 0x0000, (0x17, 0x43)) #=> RMB1 $43
expected = int('01010101', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# RMB2
@ -542,9 +542,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('11111111',2)
self._write(mpu.memory, 0x0000, (0x27, 0x43)) #=> RMB2 $43
expected = int('01010101', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# RMB3
@ -563,9 +563,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('11111111',2)
self._write(mpu.memory, 0x0000, (0x37, 0x43)) #=> RMB3 $43
expected = int('01010101', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# RMB4
@ -584,9 +584,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('11111111',2)
self._write(mpu.memory, 0x0000, (0x47, 0x43)) #=> RMB4 $43
expected = int('01010101', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# RMB5
@ -605,9 +605,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('11111111',2)
self._write(mpu.memory, 0x0000, (0x57, 0x43)) #=> RMB5 $43
expected = int('01010101', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# RMB6
@ -626,9 +626,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('11111111',2)
self._write(mpu.memory, 0x0000, (0x67, 0x43)) #=> RMB6 $43
expected = int('01010101', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# RMB7
@ -647,15 +647,15 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('11111111',2)
self._write(mpu.memory, 0x0000, (0x77, 0x43)) #=> RMB7 $43
expected = int('01010101', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# STA Zero Page, Indirect
def test_sta_zp_indirect_stores_a_leaves_a_and_n_flag_unchanged(self):
mpu = self._make_mpu()
mpu.flags = flags = 0xFF & ~(mpu.NEGATIVE)
mpu.p = flags = 0xFF & ~(mpu.NEGATIVE)
mpu.a = 0xFF
self._write(mpu.memory, 0x0000, (0x92, 0x10)) #=> STA ($0010)
self._write(mpu.memory, 0x0010, (0xED, 0xFE)) #=> Vector to $FEED
@ -665,11 +665,11 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0xFF, mpu.memory[0xFEED])
self.assertEquals(0xFF, mpu.a)
self.assertEquals(flags, mpu.flags)
self.assertEquals(flags, mpu.p)
def test_sta_zp_indirect_stores_a_leaves_a_and_z_flag_unchanged(self):
mpu = self._make_mpu()
mpu.flags = flags = 0xFF & ~(mpu.ZERO)
mpu.p = flags = 0xFF & ~(mpu.ZERO)
mpu.a = 0x00
self._write(mpu.memory, 0x0000, (0x92, 0x10)) #=> STA ($0010)
self._write(mpu.memory, 0x0010, (0xED, 0xFE)) #=> Vector to $FEED
@ -679,7 +679,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x00, mpu.memory[0xFEED])
self.assertEquals(0x00, mpu.a)
self.assertEquals(flags, mpu.flags)
self.assertEquals(flags, mpu.p)
# SMB0
@ -698,9 +698,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('00000000',2)
self._write(mpu.memory, 0x0000, (0x87, 0x43)) #=> SMB0 $43
expected = int('11001100', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# SMB1
@ -719,9 +719,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('00000000',2)
self._write(mpu.memory, 0x0000, (0x97, 0x43)) #=> SMB1 $43
expected = int('11001100', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# SMB2
@ -740,9 +740,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('00000000',2)
self._write(mpu.memory, 0x0000, (0xA7, 0x43)) #=> SMB2 $43
expected = int('11001100', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# SMB3
@ -761,9 +761,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('00000000',2)
self._write(mpu.memory, 0x0000, (0xB7, 0x43)) #=> SMB3 $43
expected = int('11001100', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# SMB4
@ -782,9 +782,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('00000000',2)
self._write(mpu.memory, 0x0000, (0xC7, 0x43)) #=> SMB4 $43
expected = int('11001100', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# SMB5
@ -803,9 +803,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('00000000',2)
self._write(mpu.memory, 0x0000, (0xD7, 0x43)) #=> SMB5 $43
expected = int('11001100', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# SMB6
@ -824,9 +824,9 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('00000000',2)
self._write(mpu.memory, 0x0000, (0xE7, 0x43)) #=> SMB6 $43
expected = int('11001100', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# SMB7
@ -845,16 +845,16 @@ class MPUTests(unittest.TestCase, Common6502Tests):
mpu.memory[0x0043] = int('00000000',2)
self._write(mpu.memory, 0x0000, (0xF7, 0x43)) #=> SMB7 $43
expected = int('11001100', 2)
mpu.flags = expected
mpu.p = expected
mpu.step()
self.assertEquals(expected, mpu.flags)
self.assertEquals(expected, mpu.p)
# SBC Zero Page, Indirect
def test_sbc_zp_indirect_all_zeros_and_no_borrow_is_zero(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.DECIMAL)
mpu.flags |= mpu.CARRY # borrow = 0
mpu.p &= ~(mpu.DECIMAL)
mpu.p |= mpu.CARRY # borrow = 0
mpu.a = 0x00
self._write(mpu.memory, 0x0000, (0xF2, 0x10)) #=> SBC ($10)
self._write(mpu.memory, 0x0010, (0xED, 0xFE)) #=> Vector to $FEED
@ -863,14 +863,14 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x00, mpu.a)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
self.assertEquals(mpu.CARRY, mpu.CARRY)
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
def test_sbc_zp_indirect_downto_zero_no_borrow_sets_z_clears_n(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.DECIMAL)
mpu.flags |= mpu.CARRY # borrow = 0
mpu.p &= ~(mpu.DECIMAL)
mpu.p |= mpu.CARRY # borrow = 0
mpu.a = 0x01
self._write(mpu.memory, 0x0000, (0xF2, 0x10)) #=> SBC ($10)
self._write(mpu.memory, 0x0010, (0xED, 0xFE)) #=> Vector to $FEED
@ -879,14 +879,14 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x00, mpu.a)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
self.assertEquals(mpu.CARRY, mpu.CARRY)
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
def test_sbc_zp_indirect_downto_zero_with_borrow_sets_z_clears_n(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.DECIMAL)
mpu.flags &= ~(mpu.CARRY) # borrow = 1
mpu.p &= ~(mpu.DECIMAL)
mpu.p &= ~(mpu.CARRY) # borrow = 1
mpu.a = 0x01
self._write(mpu.memory, 0x0000, (0xF2, 0x10)) #=> SBC ($10)
self._write(mpu.memory, 0x0010, (0xED, 0xFE)) #=> Vector to $FEED
@ -895,14 +895,14 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x00, mpu.a)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
self.assertEquals(mpu.CARRY, mpu.CARRY)
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
def test_sbc_zp_indirect_downto_four_with_borrow_clears_z_n(self):
mpu = self._make_mpu()
mpu.flags &= ~(mpu.DECIMAL)
mpu.flags &= ~(mpu.CARRY) # borrow = 1
mpu.p &= ~(mpu.DECIMAL)
mpu.p &= ~(mpu.CARRY) # borrow = 1
mpu.a = 0x07
self._write(mpu.memory, 0x0000, (0xF2, 0x10)) #=> SBC ($10)
self._write(mpu.memory, 0x0010, (0xED, 0xFE)) #=> Vector to $FEED
@ -911,8 +911,8 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
self.assertEquals(0x04, mpu.a)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.ZERO)
self.assertEquals(mpu.CARRY, mpu.CARRY)
# STZ Zero Page
@ -975,7 +975,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0xE0, mpu.memory[0x00BB])
mpu.step()
self.assertEquals(0xF0, mpu.memory[0x00BB])
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
@ -987,7 +987,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x80, mpu.memory[0x00BB])
mpu.step()
self.assertEquals(0xE0, mpu.memory[0x00BB])
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(0, mpu.p & mpu.ZERO)
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
@ -1002,7 +1002,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0xE0, mpu.memory[0xFEED])
mpu.step()
self.assertEquals(0xF0, mpu.memory[0xFEED])
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
self.assertEquals(0x0003, mpu.pc)
self.assertEquals(6, mpu.processorCycles)
@ -1014,7 +1014,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x80, mpu.memory[0xFEED])
mpu.step()
self.assertEquals(0xE0, mpu.memory[0xFEED])
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(0, mpu.p & mpu.ZERO)
self.assertEquals(0x0003, mpu.pc)
self.assertEquals(6, mpu.processorCycles)
@ -1028,7 +1028,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0xE0, mpu.memory[0x00BB])
mpu.step()
self.assertEquals(0x80, mpu.memory[0x00BB])
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
@ -1040,7 +1040,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x80, mpu.memory[0x00BB])
mpu.step()
self.assertEquals(0x80, mpu.memory[0x00BB])
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(0, mpu.p & mpu.ZERO)
self.assertEquals(0x0002, mpu.pc)
self.assertEquals(5, mpu.processorCycles)
@ -1055,7 +1055,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0xE0, mpu.memory[0xFEED])
mpu.step()
self.assertEquals(0x80, mpu.memory[0xFEED])
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
self.assertEquals(0x0003, mpu.pc)
self.assertEquals(6, mpu.processorCycles)
@ -1067,7 +1067,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self.assertEquals(0x80, mpu.memory[0xFEED])
mpu.step()
self.assertEquals(0x80, mpu.memory[0xFEED])
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(0, mpu.p & mpu.ZERO)
self.assertEquals(0x0003, mpu.pc)
self.assertEquals(6, mpu.processorCycles)
@ -1076,8 +1076,8 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self._write(mpu.memory, 0x0000, [0x3A]) #=> DEC A
mpu.a = 0x48
mpu.step()
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.ZERO)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
self.assertEquals(0x47, mpu.a)
def test_dec_a_sets_zero_flag(self):
@ -1085,8 +1085,8 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self._write(mpu.memory, 0x0000, [0x3A]) #=> DEC A
mpu.a = 0x01
mpu.step()
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
self.assertEquals(0, mpu.flags & mpu.NEGATIVE)
self.assertEquals(mpu.ZERO, mpu.p & mpu.ZERO)
self.assertEquals(0, mpu.p & mpu.NEGATIVE)
self.assertEquals(0x00, mpu.a)
def test_dec_a_wraps_at_zero(self):
@ -1094,8 +1094,8 @@ class MPUTests(unittest.TestCase, Common6502Tests):
self._write(mpu.memory, 0x0000, [0x3A]) #=> DEC A
mpu.a = 0x00
mpu.step()
self.assertEquals(0, mpu.flags & mpu.ZERO)
self.assertEquals(mpu.NEGATIVE, mpu.flags & mpu.NEGATIVE)
self.assertEquals(0, mpu.p & mpu.ZERO)
self.assertEquals(mpu.NEGATIVE, mpu.p & mpu.NEGATIVE)
self.assertEquals(0xFF, mpu.a)
def test_bra_forward(self):