-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.py
189 lines (144 loc) · 4.32 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
"""
This moduele holds all defined errors with it's definitions
Each error should contain it's own definition, with descriptio abot what hapened
which triggered en error
"""
### REGISTER ERRORS
class RegisterNotImplemented (Exception):
"""
This error occurs when you try to call an operation on non existing register
"""
pass
class RegisterTooSmallToMove (Exception):
"""
This errro occurs when you try to perform move operation on registers
which is too small to hold the value
ex.
mov ah,ax
"""
pass
class RegisterSizeTooSmall (Exception):
"""
This error occurs when you try to move value to the register which is not
big enough to hold the value
ex.
mov ah, 300
"""
pass
class OperationNotPossible (Exception):
"""
This error occurs when you try to perform an operation which is not
possible due to architecture limitation of 16-bit assebly programming
ex.
- mov [variable1],[variable2] # operation from memory to memoery directly
"""
pass
class RegisterCantEffectiveAddress (Exception):
"""
It is not possible to get the effective address from the register
In most cases it meant, that you tried to store and access value of
a variable from register which can't allow that (architecture reasons)
As a reminder - you can only get effective address of a variable from
DX(DH/DL) or BX(BH/BL) registers
"""
pass
class RegisterNotWritable (Exception):
"""
This error occurs when you try to write something to register which is not
ment to be written to
In 16-bit assembly it is `sp` register (stack pointer register)
"""
pass
### FUNCTION ERROR
class EmptyLine (Exception):
"""
This error occurs when there is an empty line
Although, technicly, en error, this one is rather to be
later use by program, to internally deal with empty lines in file
IMPORTANT:
As an empty line we categorize each line, which does not contain
actual code - this include both lines with comments only and 'physically'
empty lines in file
EX - each line would raise error:
1. ' '
2. ' ;ajsjaslkaj '
3. ''
"""
pass
class ArgumentNotExpected (Exception):
"""
This error occurs if function tried to be executed while not needing
any parametres
EX:
PUSHA DX <- this is not needed here, so this error would be raised
"""
pass
class NotEnoughArguments (Exception):
"""
This error is raised, if function tries to be executed, while not having
enough parametres passed
EX:
'ADD AX,'
'ADD '
'ADD'
"""
pass
class TooManyArgumentsToUnpack (Exception):
"""
This error is passed if funciton is run having passed too many params
EX:
'ADD AX, BX, CX'
'INC AX, BX'
"""
pass
### NUMBER ERROR
class WrongNumberBase (Exception):
"""
To be implemented later
"""
pass
class NumberTooBig (Exception):
"""
Provided number is too big for a given register
ex.
mov ah,2987 (obviously, 8 bit register can't hold such a big number)
"""
pass
class NumberSizeRequired (Exception):
"""
This error indicated that you have to explicitly provide size
of the number - dw, dt, word etc.
"""
pass
class CantPushValueTooBig (Exception):
"""
This error indicates that you are trying to push value greater
than 16 bit onto stack
"""
pass
### OTHER ERRORS
class OperandSizeNotSpecified (Exception):
"""
This error indicated that you have to explicitly provide size
of the operation - dw, dt, word etc.
"""
pass
class EffectiveAddressError (Exception):
"""
This error indicated that you propably misspelled hence program
couldn't understant how paranthesis should be read
"""
pass
class EffectiveAddresNotExist (Exception):
"""
This error indicates, that the effective address you are trying to access
does not exist - this doesn't have to be prohibited in the assembly itslef,
but it's unsafe it's rather a mistake than an expected behaviour
"""
pass
class VariableAddressNotExisting (Exception):
"""
This error indicated that you used name of variable which is not
defined - propably a writing mistake
"""
pass