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]