diff --git a/src/vm.py b/src/vm.py index 3f03d49..e2427b5 100644 --- a/src/vm.py +++ b/src/vm.py @@ -21,6 +21,9 @@ class VMCC(IntFlag): NEGATIVE = 1 << 1 ZERO = 1 << 0 +class Breakpoint(Exception): + address: int + @dataclass class VM: instr_callbacks: ClassVar[dict[OpcodeDescription, Callable]] @@ -114,11 +117,10 @@ class VM: """ Continue from current breakpoint """ - while ((self.pc.value < len(self.mem) // 4) - and not self.pc.value in self.breakpoints): + while self.pc.value < len(self.mem): + if self.pc.value in self.breakpoints: + raise Breakpoint(self.pc.value) self.step() - print("breakpoint") - input() def run(self) -> None: """