forked from Sonalisinghal/Two-Pass-Assembler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.py
65 lines (46 loc) · 2.19 KB
/
errors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from opcodes import opcodes, opcode_arguments
class SymbolNotDefined(Error):
def __init__(self,sym):
Error.__init__(self,str(sym)+" symbol is not defined")
class MultipleSymbolDefinitions(Error):
def __init__(self,sym):
Error.__init__(self,str(sym)+" symbol has been defined more than once")
# class MultipleRegisterDefinitions(Error):
# def __init__(self,reg):
# Error.__init__(self,str(reg)+" register has been defined more than once")
class IncorrectNumberofOperands(Error):
def __init__(self,op,num):
Error.__init__(self,str(op)+" requires "+str(opcode_arguments[op])+" operands. "+str(num)+" supplied")
# class RegisterExceed(Error):
# def __init__(self,num):
# Error.__init__(self,str(num)+" exceeds the number of registers. Maximum number of registers are __")
class NoEnd(Error):
def __init__(self):
Error.__init__("Could not find END statement. Put END at the end of the assembly code")
class IllegalLabelName(Error):
def __init__(self,l):
Error.__init__(str(l)+" label name is not allowed as it is a valid opcode")
class IllegalOperand(Error):
def __init__(self,op,actual, expected):
Error.__init__("You tried using an invalid combination of opcode and operands. Got "+str(actual)+". "str(op)+" requires a "+str(expected)+" argument.")
class IllegalOpcode(Error):
def __init__(self,op):
Error.__init__(self,str(op)+" is not a valid opcode")
class AddressOutOfBounds(Error):
def __init__(self,address):
Error.__init__(self,str(address)+" does not exist")
class AddressIsLiteral(Error):
def __init__(self,address):
Error.__init__(self,str(address)+" is a read only address as it contains a constant")
class AddressIsInstruction(Error): # can be encountered during runtime
def __init__(self,address):
Error.__init__(self,str(address)+" is a read only address as it contains an Instruction")
class AddressUndefined(Error):
def __init__(self,address,op):
Error.__init__(self,"Cannot perform operation "+str(op)+" as "+str(addess)+" is undefined")
class IllegalMacroName(Error):
def __init__(self,mname):
Error.__init__(self,"Name of the Macro "+str(mname)+" is already an existing label/Opcode")
#illegal address
#int or float expected
#label name cannot be an opcode name