feat: improve output when CPU halts
This commit is contained in:
parent
f6dd24732e
commit
4e71d8ee21
1 changed files with 5 additions and 4 deletions
|
@ -298,19 +298,20 @@ class CPU(object):
|
||||||
return "%04X %s %s" % (addr, instruction.__name__.lower(), self.addr_fmt[addressing](addr+1)), addr + self.ticks[addressing] + 1
|
return "%04X %s %s" % (addr, instruction.__name__.lower(), self.addr_fmt[addressing](addr+1)), addr + self.ticks[addressing] + 1
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
self.executed.append(self.pc)
|
|
||||||
|
|
||||||
opcode = self.memory[self.pc]
|
opcode = self.memory[self.pc]
|
||||||
self.pc = self.pc + 1 & 0xFFFF
|
|
||||||
|
|
||||||
if opcode not in self._opcodes:
|
if opcode not in self._opcodes:
|
||||||
print('HALT')
|
print('HALT')
|
||||||
for addr in self.executed:
|
for addr in self.executed:
|
||||||
code, _ = self.disasm(addr)
|
code, _ = self.disasm(addr)
|
||||||
print(" - %s" % code)
|
print(" - %s" % code)
|
||||||
|
print(" > %04x %02x %02x" % (self.pc, self.memory[self.pc], self.memory[self.pc+1]))
|
||||||
|
|
||||||
|
self.executed.append(self.pc)
|
||||||
|
self.pc = self.pc + 1 & 0xFFFF
|
||||||
|
|
||||||
instruction, addressing, cycles = self._opcodes[opcode]
|
instruction, addressing, cycles = self._opcodes[opcode]
|
||||||
instruction(addressing())
|
instruction(addressing())
|
||||||
|
|
||||||
self.pc += self.ticks[addressing]
|
self.pc += self.ticks[addressing]
|
||||||
if len(self.executed) > 20:
|
if len(self.executed) > 20:
|
||||||
self.executed = self.executed[1:]
|
self.executed = self.executed[1:]
|
||||||
|
|
Loading…
Reference in a new issue