From 4e71d8ee217a9535fc12800c65078537865dedac Mon Sep 17 00:00:00 2001 From: shokre Date: Thu, 25 Nov 2021 02:41:18 +0100 Subject: [PATCH] feat: improve output when CPU halts --- orao/cpu.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/orao/cpu.py b/orao/cpu.py index 0ff185d..87bc69f 100755 --- a/orao/cpu.py +++ b/orao/cpu.py @@ -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 def step(self): - self.executed.append(self.pc) - opcode = self.memory[self.pc] - self.pc = self.pc + 1 & 0xFFFF - if opcode not in self._opcodes: print('HALT') for addr in self.executed: code, _ = self.disasm(addr) 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()) + self.pc += self.ticks[addressing] if len(self.executed) > 20: self.executed = self.executed[1:]