CPU/error.py

30 lines
502 B
Python
Raw Normal View History

2024-05-07 16:47:19 +08:00
class MemoryError(Exception):
2024-04-29 16:00:03 +08:00
pass
2024-05-02 08:54:42 +08:00
2024-05-07 16:47:19 +08:00
class AddressError(MemoryError):
def __init__(self, index=None):
super().__init__(self)
if not index:
self.errorinfo = "None"
else:
self.errorinfo = str(hex(index))
2024-04-29 22:03:14 +08:00
2024-05-07 16:47:19 +08:00
def __str__(self):
return self.errorinfo
2024-05-02 08:54:42 +08:00
2024-05-07 16:47:19 +08:00
class OutOfMemory(MemoryError):
2024-04-29 22:03:14 +08:00
pass
2024-05-02 08:54:42 +08:00
2024-04-29 22:03:14 +08:00
class InstructionError(Exception):
pass
2024-05-02 08:54:42 +08:00
2024-04-29 22:03:14 +08:00
class InvalidInstruction(InstructionError):
pass
2024-05-02 08:54:42 +08:00
2024-04-29 22:03:14 +08:00
class BadOperand(InstructionError):
2024-05-02 08:54:42 +08:00
pass
2024-05-07 16:47:19 +08:00