mirror of
https://github.com/mnaberez/py65.git
synced 2025-08-08 13:25:01 +00:00
Speed up run() by using sets for stopcodes and breakpoints
This commit is contained in:
@@ -436,22 +436,25 @@ class Monitor(cmd.Cmd):
|
|||||||
brks = [0x00] # BRK
|
brks = [0x00] # BRK
|
||||||
self._run(stopcodes=brks)
|
self._run(stopcodes=brks)
|
||||||
|
|
||||||
def _run(self, stopcodes=[]):
|
def _run(self, stopcodes):
|
||||||
last_instruct = None
|
stopcodes = set(stopcodes)
|
||||||
if not self._breakpoints:
|
breakpoints = set(self._breakpoints)
|
||||||
while last_instruct not in stopcodes:
|
|
||||||
|
if not breakpoints: # optimization
|
||||||
|
while True:
|
||||||
self._mpu.step()
|
self._mpu.step()
|
||||||
last_instruct = self._mpu.memory[self._mpu.pc]
|
if self._mpu.memory[self._mpu.pc] in stopcodes:
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
# Slows things down quite a bit, unfortunately.
|
while True:
|
||||||
breakpoint = False
|
|
||||||
while last_instruct not in stopcodes and not breakpoint:
|
|
||||||
self._mpu.step()
|
self._mpu.step()
|
||||||
last_instruct = self._mpu.memory[self._mpu.pc]
|
pc = self._mpu.pc
|
||||||
if self._mpu.pc in self._breakpoints:
|
if self._mpu.memory[pc] in stopcodes:
|
||||||
|
break
|
||||||
|
if pc in breakpoints:
|
||||||
msg = "Breakpoint %d reached."
|
msg = "Breakpoint %d reached."
|
||||||
self._output(msg % self._breakpoints.index(self._mpu.pc))
|
self._output(msg % self._breakpoints.index(pc))
|
||||||
breakpoint = True
|
break
|
||||||
|
|
||||||
def help_radix(self):
|
def help_radix(self):
|
||||||
self._output("radix [H|D|O|B]")
|
self._output("radix [H|D|O|B]")
|
||||||
|
Reference in New Issue
Block a user