From 44f3e622c890acd52b8a491248639d9e8479bdd4 Mon Sep 17 00:00:00 2001 From: ElectronixTM Date: Mon, 31 Mar 2025 03:02:56 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BF=D0=B8=D1=81=D0=B0=D1=82=D1=8C=20=D1=81?= =?UTF-8?q?=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=B1?= =?UTF-8?q?=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=D1=85=20=D0=BA=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=D0=BC=20?= =?UTF-8?q?=D0=B2=D0=B8=D1=80=D0=B0=D1=82=D1=83=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=BC=D0=B0=D1=88=D0=B8=D0=BD=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/emulator/__init__.py | 0 src/{ => emulator}/main.py | 0 src/{ => emulator}/optable.py | 0 src/{ => emulator}/vm.py | 7 +++++-- 4 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 src/emulator/__init__.py rename src/{ => emulator}/main.py (100%) rename src/{ => emulator}/optable.py (100%) rename src/{ => emulator}/vm.py (98%) diff --git a/src/emulator/__init__.py b/src/emulator/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/main.py b/src/emulator/main.py similarity index 100% rename from src/main.py rename to src/emulator/main.py diff --git a/src/optable.py b/src/emulator/optable.py similarity index 100% rename from src/optable.py rename to src/emulator/optable.py diff --git a/src/vm.py b/src/emulator/vm.py similarity index 98% rename from src/vm.py rename to src/emulator/vm.py index b2d9b8e..f46a060 100644 --- a/src/vm.py +++ b/src/emulator/vm.py @@ -37,6 +37,7 @@ class VMExceptionType(Enum): class VMException(Exception): cause: VMExceptionType pc: int + message: str = "" @dataclass class VM: @@ -125,7 +126,8 @@ class VM: if self._to_raw_bytes_offset(self.pc) > len(self.mem) - WORD_SIZE: raise VMException( VMExceptionType.END_OF_MEM, - self.pc.value + self.pc.value, + "couldn't perform step because end of memory occured" ) opcode, *_ = instr = self._fetch_instr() opdesc = self._get_opcode_desc(opcode) @@ -175,7 +177,8 @@ class VM: if not opcode in OPCODES: raise VMException( VMExceptionType.INVALID_OPCODE, - self.pc.value + self.pc.value, + f"Couldn't resolve an opcode {hex(opcode)}" ) return OPCODES[opcode]