1
0
mirror of https://github.com/mnaberez/py65.git synced 2024-06-01 18:41:32 +00:00

Changed __repr__ of MPU objects to show flags in binary.

This commit is contained in:
Mike Naberezny 2009-08-16 19:10:57 -07:00
parent cb63d94776
commit a5482c1e1b
4 changed files with 15 additions and 8 deletions

View File

@ -10,6 +10,9 @@ Next Release
in the monitor using the "registers" command with an argument of
"p", such as "registers p=00".
- MPU objects now return a two-line string as their __repr__ with
the processor status register displayed as binary for readability.
0.6 (2009-08-11)
- Added monitor shortcut "a" for "assemble".

View File

@ -1,5 +1,6 @@
from py65.utils.conversions import convert_to_bin, convert_to_bcd
from py65.utils.conversions import convert_to_bin, convert_to_bcd, itoa
from py65.utils.devices import make_instruction_decorator
from os import linesep
class MPU:
# vectors
@ -36,9 +37,14 @@ class MPU:
self.reset()
def __repr__(self):
out = '<%s: A=%02x, X=%02x, Y=%02x, Flags=%02x, SP=%02x, PC=%04x>'
return out % (self.name, self.a, self.x, self.y,
self.flags, self.sp, self.pc)
flags = itoa(self.flags, 2).rjust(8, '0')
indent = ' ' * (len(self.name) + 2)
out = "%s PC AC XR YR SP NV-BDIZC" + linesep + \
"%s: %04x %02x %02x %02x %02x %s"
return out % (indent, self.name,
self.pc, self.a, self.x, self.y, self.pc, flags)
def step(self):
instructCode = self.ImmediateByte()

View File

@ -4750,8 +4750,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
def test_repr(self):
mpu = self._make_mpu()
self.assertEquals('<6502: A=00, X=00, Y=00, Flags=20, SP=ff, PC=0000>',
repr(mpu))
self.assert_("6502" in repr(mpu))
def test_stz_not_supported(self):
mpu = self._make_mpu(debug=True)

View File

@ -9,8 +9,7 @@ class MPUTests(unittest.TestCase, Common6502Tests):
def test_repr(self):
mpu = self._make_mpu()
self.assertEquals('<65C02: A=00, X=00, Y=00, Flags=20, SP=ff, PC=0000>',
repr(mpu))
self.assert_('65C02' in repr(mpu))
# ADC Zero Page, Indirect