File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -105,8 +105,8 @@ def assemble(text_program):
105
105
if len (instruction ) > 2 :
106
106
try :
107
107
assembled [- 1 ] |= CONDITIONS .index (instruction [1 ]) << 5
108
- except ValueError :
109
- raise SyntaxError (f"Invalid jmp condition { instruction [1 ]} " )
108
+ except ValueError as exc :
109
+ raise SyntaxError (f"Invalid jmp condition { instruction [1 ]} " ) from exc
110
110
111
111
elif instruction [0 ] == "wait" :
112
112
# instr delay p sr index
@@ -154,7 +154,10 @@ def assemble(text_program):
154
154
source = instruction [- 1 ]
155
155
source_split = mov_splitter (source )
156
156
if len (source_split ) == 1 :
157
- assembled [- 1 ] |= MOV_SOURCES .index (source )
157
+ try :
158
+ assembled [- 1 ] |= MOV_SOURCES .index (source )
159
+ except ValueError as exc :
160
+ raise RuntimeError ("Invalid mov source:" , source ) from exc
158
161
else :
159
162
assembled [- 1 ] |= MOV_SOURCES .index (source_split [1 ])
160
163
if source [:1 ] == "!" :
@@ -188,8 +191,8 @@ def assemble(text_program):
188
191
assembled .append (0b111_00000_000_00000 )
189
192
try :
190
193
assembled [- 1 ] |= SET_DESTINATIONS .index (instruction [1 ]) << 5
191
- except ValueError :
192
- raise RuntimeError (f"Uknnown set destination { instruction [1 ]} " )
194
+ except ValueError as exc :
195
+ raise RuntimeError (f"Uknnown set destination { instruction [1 ]} " ) from exc
193
196
value = int (instruction [- 1 ])
194
197
if not 0 <= value <= 31 :
195
198
raise RuntimeError ("Set value out of range" )
You can’t perform that action at this time.
0 commit comments