From fe5d51258b9366cc3eda246ca6b7f80355db322f Mon Sep 17 00:00:00 2001 From: ElectronixTM Date: Sat, 29 Mar 2025 01:03:55 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D1=81=D1=82=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=B5=D0=BA=20=D0=BE=D1=81=D1=82=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/vm.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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: """