@@ -69,7 +69,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
6969 raise RuntimeError ("Cannot have .wrap as first instruction" )
7070 wrap = len (instructions ) - 1
7171 elif line .startswith (".side_set" ):
72- sideset_count = int (line .split ()[1 ])
72+ sideset_count = int (line .split ()[1 ], 0 )
7373 sideset_enable = "opt" in line
7474 elif line .endswith (":" ):
7575 label = line [:- 1 ]
@@ -88,7 +88,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
8888 instruction = splitter (instruction .strip ())
8989 delay = 0
9090 if instruction [- 1 ].endswith ("]" ): # Delay
91- delay = int (instruction [- 1 ].strip ("[]" ))
91+ delay = int (instruction [- 1 ].strip ("[]" ), 0 )
9292 if delay < 0 :
9393 raise RuntimeError ("Delay negative:" , delay )
9494 if delay > max_delay :
@@ -97,7 +97,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
9797 if len (instruction ) > 1 and instruction [- 2 ] == "side" :
9898 if sideset_count == 0 :
9999 raise RuntimeError ("No side_set count set" )
100- sideset_value = int (instruction [- 1 ])
100+ sideset_value = int (instruction [- 1 ], 0 )
101101 if sideset_value >= 2 ** sideset_count :
102102 raise RuntimeError ("Sideset value too large" )
103103 delay |= sideset_value << (5 - sideset_count - sideset_enable )
@@ -113,7 +113,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
113113 assembled .append (0b000_00000_000_00000 )
114114 target = instruction [- 1 ]
115115 if target [:1 ] in "0123456789" :
116- assembled [- 1 ] |= int (target )
116+ assembled [- 1 ] |= int (target , 0 )
117117 elif instruction [- 1 ] in labels :
118118 assembled [- 1 ] |= labels [target ]
119119 else :
@@ -130,12 +130,12 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
130130 elif instruction [0 ] == "wait" :
131131 # instr delay p sr index
132132 assembled .append (0b001_00000_0_00_00000 )
133- polarity = int (instruction [1 ])
133+ polarity = int (instruction [1 ], 0 )
134134 if not 0 <= polarity <= 1 :
135135 raise RuntimeError ("Invalid polarity" )
136136 assembled [- 1 ] |= polarity << 7
137137 assembled [- 1 ] |= WAIT_SOURCES .index (instruction [2 ]) << 5
138- num = int (instruction [3 ])
138+ num = int (instruction [3 ], 0 )
139139 if not 0 <= num <= 31 :
140140 raise RuntimeError ("Wait num out of range" )
141141 assembled [- 1 ] |= num
@@ -145,15 +145,15 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
145145 # instr delay src count
146146 assembled .append (0b010_00000_000_00000 )
147147 assembled [- 1 ] |= IN_SOURCES .index (instruction [1 ]) << 5
148- count = int (instruction [- 1 ])
148+ count = int (instruction [- 1 ], 0 )
149149 if not 1 <= count <= 32 :
150150 raise RuntimeError ("Count out of range" )
151151 assembled [- 1 ] |= count & 0x1F # 32 is 00000 so we mask the top
152152 elif instruction [0 ] == "out" :
153153 # instr delay dst count
154154 assembled .append (0b011_00000_000_00000 )
155155 assembled [- 1 ] |= OUT_DESTINATIONS .index (instruction [1 ]) << 5
156- count = int (instruction [- 1 ])
156+ count = int (instruction [- 1 ], 0 )
157157 if not 1 <= count <= 32 :
158158 raise RuntimeError ("Count out of range" )
159159 assembled [- 1 ] |= count & 0x1F # 32 is 00000 so we mask the top
@@ -195,7 +195,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
195195 if instruction [- 1 ] == "rel" :
196196 assembled [- 1 ] |= 0x10 # Set the high bit of the irq value
197197 instruction .pop ()
198- num = int (instruction [- 1 ])
198+ num = int (instruction [- 1 ], 0 )
199199 if not 0 <= num <= 7 :
200200 raise RuntimeError ("Interrupt index out of range" )
201201 assembled [- 1 ] |= num
@@ -214,7 +214,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
214214 raise ValueError (
215215 f"Invalid set destination '{ instruction [1 ]} '"
216216 ) from exc
217- value = int (instruction [- 1 ])
217+ value = int (instruction [- 1 ], 0 )
218218 if not 0 <= value <= 31 :
219219 raise RuntimeError ("Set value out of range" )
220220 assembled [- 1 ] |= value
0 commit comments