diff --git a/CHANGES.txt b/CHANGES.txt index b796cfb..21bb113 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,6 +13,9 @@ Next Release - MPU objects now return a two-line string as their __repr__ with the processor status register displayed as binary for readability. + - The processor status register is now initialized to 0 on reset. + Previously, its unused bit (bit 5) was set to 1 on reset. + 0.6 (2009-08-11) - Added monitor shortcut "a" for "assemble". diff --git a/src/py65/devices/mpu6502.py b/src/py65/devices/mpu6502.py index 0a3c5ae..035a918 100644 --- a/src/py65/devices/mpu6502.py +++ b/src/py65/devices/mpu6502.py @@ -44,7 +44,7 @@ class MPU: "%s: %04x %02x %02x %02x %02x %s" return out % (indent, self.name, - self.pc, self.a, self.x, self.y, self.pc, flags) + self.pc, self.a, self.x, self.y, self.sp, flags) def step(self): instructCode = self.ImmediateByte() @@ -63,7 +63,7 @@ class MPU: self.a = 0 self.x = 0 self.y = 0 - self.flags = self.UNUSED + self.flags = 0 self.processorCycles = 0 # Helpers for addressing modes diff --git a/src/py65/tests/devices/test_mpu6502.py b/src/py65/tests/devices/test_mpu6502.py index c0e8676..ba01c2d 100644 --- a/src/py65/tests/devices/test_mpu6502.py +++ b/src/py65/tests/devices/test_mpu6502.py @@ -6,6 +6,17 @@ import py65.devices.mpu6502 class Common6502Tests: """Tests common to 6502-based microprocessors""" + # Reset + + def test_reset_sets_registers_to_initial_states(self): + mpu = self._make_mpu() + mpu.reset() + self.assertEquals(0xFF, mpu.sp) + self.assertEquals(0, mpu.a) + self.assertEquals(0, mpu.x) + self.assertEquals(0, mpu.y) + self.assertEquals(0, mpu.flags) + # ADC Absolute def test_adc_bcd_off_absolute_carry_clear_in_accumulator_zeroes(self):