File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,9 @@ def assemble(text_program):
103103 raise SyntaxError (f"Invalid jmp target { repr (target )} " )
104104
105105 if len (instruction ) > 2 :
106- assembled [- 1 ] |= CONDITIONS .index (instruction [1 ]) << 5
106+ try :
107+ assembled [- 1 ] |= CONDITIONS .index (instruction [1 ]) << 5
108+ raise SyntaxError (f"Invalid jmp condition { instruction [1 ]} " )
107109
108110 elif instruction [0 ] == "wait" :
109111 # instr delay p sr index
@@ -183,7 +185,10 @@ def assemble(text_program):
183185 elif instruction [0 ] == "set ":
184186 # instr delay dst data
185187 assembled .append (0b111_00000_000_00000 )
186- assembled [- 1 ] |= SET_DESTINATIONS .index (instruction [1 ]) << 5
188+ try :
189+ assembled [- 1 ] |= SET_DESTINATIONS .index (instruction [1 ]) << 5
190+ except ValueError :
191+ raise RuntimeError (f"Uknnown set destination { instruction [1 ]} " )
187192 value = int (instruction [- 1 ])
188193 if not 0 <= value <= 31 :
189194 raise RuntimeError ("Set value out of range" )
You can’t perform that action at this time.
0 commit comments