@@ -325,19 +325,33 @@ def int_in_range(arg, low, high, what, radix=0):
325
325
if len (instruction ) > 3 :
326
326
assembled [- 1 ] |= MOV_OPS .index (instruction [- 2 ]) << 3
327
327
elif instruction [0 ] == "irq" :
328
- # instr delay z c w index
328
+ # instr delay z c w tp/idx
329
329
assembled .append (0b110_00000_0_0_0_00000 )
330
- if instruction [- 1 ] == "rel" :
331
- assembled [- 1 ] |= 0x10 # Set the high bit of the irq value
330
+
331
+ irq_type = 0
332
+ print (f"check prev/next/rel { instruction = } " )
333
+ if instruction [- 1 ] == "prev" :
334
+ irq_type = 1
335
+ require_version (1 , "irq prev" )
336
+ instruction .pop ()
337
+ elif instruction [- 1 ] == "next" :
338
+ irq_type = 3
339
+ require_version (1 , "irq next" )
340
+ instruction .pop ()
341
+ elif instruction [- 1 ] == "rel" :
342
+ irq_type = 2
332
343
instruction .pop ()
333
- num = int (instruction [- 1 ], 0 )
334
- if not 0 <= num <= 7 :
335
- raise RuntimeError ("Interrupt index out of range" )
344
+
345
+ assembled [- 1 ] |= irq_type << 3
346
+
347
+ num = int_in_range (instruction [- 1 ], 0 , 8 , "irq index" )
336
348
assembled [- 1 ] |= num
337
- if len (instruction ) == 3 : # after rel has been removed
338
- if instruction [1 ] == "wait" :
349
+ instruction .pop ()
350
+
351
+ if len (instruction ) > 1 : # after rel has been removed
352
+ if instruction [- 1 ] == "wait" :
339
353
assembled [- 1 ] |= 0x20
340
- elif instruction [1 ] == "clear" :
354
+ elif instruction [- 1 ] == "clear" :
341
355
assembled [- 1 ] |= 0x40
342
356
# All other values are the default of set without waiting
343
357
elif instruction [0 ] == "set" :
0 commit comments