@@ -69,7 +69,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
69
69
raise RuntimeError ("Cannot have .wrap as first instruction" )
70
70
wrap = len (instructions ) - 1
71
71
elif line .startswith (".side_set" ):
72
- sideset_count = int (line .split ()[1 ])
72
+ sideset_count = int (line .split ()[1 ], 0 )
73
73
sideset_enable = "opt" in line
74
74
elif line .endswith (":" ):
75
75
label = line [:- 1 ]
@@ -88,7 +88,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
88
88
instruction = splitter (instruction .strip ())
89
89
delay = 0
90
90
if instruction [- 1 ].endswith ("]" ): # Delay
91
- delay = int (instruction [- 1 ].strip ("[]" ))
91
+ delay = int (instruction [- 1 ].strip ("[]" ), 0 )
92
92
if delay < 0 :
93
93
raise RuntimeError ("Delay negative:" , delay )
94
94
if delay > max_delay :
@@ -97,7 +97,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
97
97
if len (instruction ) > 1 and instruction [- 2 ] == "side" :
98
98
if sideset_count == 0 :
99
99
raise RuntimeError ("No side_set count set" )
100
- sideset_value = int (instruction [- 1 ])
100
+ sideset_value = int (instruction [- 1 ], 0 )
101
101
if sideset_value >= 2 ** sideset_count :
102
102
raise RuntimeError ("Sideset value too large" )
103
103
delay |= sideset_value << (5 - sideset_count - sideset_enable )
@@ -113,7 +113,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
113
113
assembled .append (0b000_00000_000_00000 )
114
114
target = instruction [- 1 ]
115
115
if target [:1 ] in "0123456789" :
116
- assembled [- 1 ] |= int (target )
116
+ assembled [- 1 ] |= int (target , 0 )
117
117
elif instruction [- 1 ] in labels :
118
118
assembled [- 1 ] |= labels [target ]
119
119
else :
@@ -130,12 +130,12 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
130
130
elif instruction [0 ] == "wait" :
131
131
# instr delay p sr index
132
132
assembled .append (0b001_00000_0_00_00000 )
133
- polarity = int (instruction [1 ])
133
+ polarity = int (instruction [1 ], 0 )
134
134
if not 0 <= polarity <= 1 :
135
135
raise RuntimeError ("Invalid polarity" )
136
136
assembled [- 1 ] |= polarity << 7
137
137
assembled [- 1 ] |= WAIT_SOURCES .index (instruction [2 ]) << 5
138
- num = int (instruction [3 ])
138
+ num = int (instruction [3 ], 0 )
139
139
if not 0 <= num <= 31 :
140
140
raise RuntimeError ("Wait num out of range" )
141
141
assembled [- 1 ] |= num
@@ -145,15 +145,15 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
145
145
# instr delay src count
146
146
assembled .append (0b010_00000_000_00000 )
147
147
assembled [- 1 ] |= IN_SOURCES .index (instruction [1 ]) << 5
148
- count = int (instruction [- 1 ])
148
+ count = int (instruction [- 1 ], 0 )
149
149
if not 1 <= count <= 32 :
150
150
raise RuntimeError ("Count out of range" )
151
151
assembled [- 1 ] |= count & 0x1F # 32 is 00000 so we mask the top
152
152
elif instruction [0 ] == "out" :
153
153
# instr delay dst count
154
154
assembled .append (0b011_00000_000_00000 )
155
155
assembled [- 1 ] |= OUT_DESTINATIONS .index (instruction [1 ]) << 5
156
- count = int (instruction [- 1 ])
156
+ count = int (instruction [- 1 ], 0 )
157
157
if not 1 <= count <= 32 :
158
158
raise RuntimeError ("Count out of range" )
159
159
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:
195
195
if instruction [- 1 ] == "rel" :
196
196
assembled [- 1 ] |= 0x10 # Set the high bit of the irq value
197
197
instruction .pop ()
198
- num = int (instruction [- 1 ])
198
+ num = int (instruction [- 1 ], 0 )
199
199
if not 0 <= num <= 7 :
200
200
raise RuntimeError ("Interrupt index out of range" )
201
201
assembled [- 1 ] |= num
@@ -214,7 +214,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
214
214
raise ValueError (
215
215
f"Invalid set destination '{ instruction [1 ]} '"
216
216
) from exc
217
- value = int (instruction [- 1 ])
217
+ value = int (instruction [- 1 ], 0 )
218
218
if not 0 <= value <= 31 :
219
219
raise RuntimeError ("Set value out of range" )
220
220
assembled [- 1 ] |= value
0 commit comments