def __repr__(self): flags = itoa(self.p, 2).rjust(8, "0") indent = " " * (len(self.name) + 2) out = "%s PC AC XR YR SP NV-BDIZC\n" + "%s: %04x %02x %02x %02x %02x %s" return out % (indent, self.name, self.pc, self.a, self.x, self.y, self.sp, flags)
def __repr__(self): flags = itoa(self.p, 2).rjust(8, '0') out = "{} PC AC XR YR SP NV-BDIZC\n{}: " if self.jammed: out += "-- -- -- -- -JAMMED-" else: out += "{:04x} {:02x} {:02x} {:02x} {:02x} {}" return out.format(' ' * len(self.name), self.name, self.pc, self.a, self.x, self.y, self.sp, flags)
def do_tilde(self, args): try: num = self._address_parser.number(args) except ValueError: self._output("Syntax error: %s" % args) return self._output("+%u" % num) self._output("$%02x" % num) self._output("%04o" % num) self._output(itoa(num, 2).zfill(8))
def do_tilde(self, args): if args == '': return self.help_tilde() try: num = self._address_parser.number(args) self._output("+%u" % num) self._output("$" + self.byteFmt % num) self._output("%04o" % num) self._output(itoa(num, 2).zfill(8)) except KeyError: self._output("Bad label: %s" % args) except OverflowError: self._output("Overflow error: %s" % args)
def __repr__(self): flags = itoa(self.p, 2).rjust(self.byteWidth, '0') indent = ' ' * (len(self.name) + 2) return self.reprformat() % (indent, self.name, self.pc, self.a, self.x, self.y, self.sp, flags)
def test_itoa_hex_output(self): self.assertEqual('a', itoa(10, base=16))
def test_itoa_decimal_output(self): self.assertEqual('10', itoa(10, base=10))
def test_itoa_bin_output(self): self.assertEqual('1010', itoa(10, base=2))
def __repr__(self): flags = itoa(self.p, 2).rjust(self.BYTE_WIDTH, '0') indent = ' ' * (len(self.name) + 2) return self.reprformat() % (indent, self.name, self.pc, self.a, self.x, self.y, self.sp, flags)
def __repr__(self): return '<CPU:%s PC=%04X A=%02X X=%02X Y=%02X SP=%02X NV-B-IZC=%s>' % ( self.name, self.pc, self.a, self.x, self.y, self.sp + 0x0100, itoa(self.p, 2).rjust(8, '0') )