1
0
mirror of https://github.com/mnaberez/py65.git synced 2024-05-31 12:41:31 +00:00

Add support for optionally tracing execution

This commit is contained in:
kris 2017-05-11 21:55:29 +01:00
parent 33b48ffbfb
commit 5e7ade9cb9
2 changed files with 9 additions and 4 deletions

View File

@ -1,6 +1,6 @@
from py65.utils.conversions import itoa
from py65.utils.devices import make_instruction_decorator
from py65 import disassembler
class MPU:
# vectors
@ -41,6 +41,8 @@ class MPU:
self.memory = memory
self.start_pc = pc
self.disassembler = disassembler.Disassembler(self)
# init
self.reset()
@ -55,8 +57,11 @@ class MPU:
return self.reprformat() % (indent, self.name, self.pc, self.a,
self.x, self.y, self.sp, flags)
def step(self):
def step(self, trace=False):
instructCode = self.memory[self.pc]
if trace:
print self, "$%04X: %s" % (
self.pc, self.disassembler.instruction_at(self.pc)[1])
self.pc = (self.pc + 1) & self.addrMask
self.excycles = 0
self.addcycles = self.extracycles[instructCode]

View File

@ -8,11 +8,11 @@ class MPU(mpu6502.MPU):
self.name = '65C02'
self.waiting = False
def step(self):
def step(self, trace=False):
if self.waiting:
self.processorCycles += 1
else:
mpu6502.MPU.step(self)
mpu6502.MPU.step(self, trace)
return self
# Make copies of the lists