@@ -64,6 +64,10 @@ def __init__(self, text_program: str, *, build_debuginfo: bool = False) -> None:
64
64
mov_status_type = None
65
65
mov_status_count = None
66
66
mov_status_param = None
67
+ in_count = None
68
+ in_shift_right = None
69
+ auto_push = None
70
+ push_threshold = None
67
71
68
72
def require_before_instruction ():
69
73
if len (instructions ) != 0 :
@@ -139,6 +143,29 @@ def int_in_range(arg, low, high, what, radix=0):
139
143
if not 0 <= mov_status_count < 16 :
140
144
raise RuntimeError (f"Invalid mov_status count { mov_status_count } " )
141
145
require_version (required_version , line )
146
+ elif words [0 ] == ".in" :
147
+ require_before_instruction ()
148
+ in_count = int_in_range (
149
+ words [1 ], 32 if pio_version == 0 else 1 , 33 , ".in count"
150
+ )
151
+ auto_push = False
152
+
153
+ idx = 2
154
+ if idx < len (words ) and words [idx ] == "left" :
155
+ in_shift_right = False
156
+ idx += 1
157
+ elif idx < len (words ) and words [idx ] == "right" :
158
+ in_shift_right = True
159
+ idx += 1
160
+
161
+ if idx < len (words ) and words [idx ] == "auto" :
162
+ auto_push = True
163
+ idx += 1
164
+
165
+ if idx < len (words ):
166
+ push_threshold = int_in_range (words [idx ], 1 , 33 , ".in threshold" )
167
+ idx += 1
168
+
142
169
elif line .endswith (":" ):
143
170
label = line [:- 1 ]
144
171
if label in labels :
@@ -326,6 +353,18 @@ def int_in_range(arg, low, high, what, radix=0):
326
353
self .pio_kwargs ["mov_status_count" ] = mov_status_count
327
354
self .pio_kwargs ["mov_status_param" ] = mov_status_param
328
355
356
+ if in_count not in (None , 32 ):
357
+ self .pio_kwargs ["in_count" ] = in_count
358
+
359
+ if in_shift_right is not None :
360
+ self .pio_kwargs ["in_shift_right" ] = in_shift_right
361
+
362
+ if auto_push is not None :
363
+ self .pio_kwargs ["auto_push" ] = auto_push
364
+
365
+ if push_threshold is not None :
366
+ self .pio_kwargs ["push_threshold" ] = push_threshold
367
+
329
368
self .assembled = array .array ("H" , assembled )
330
369
331
370
self .debuginfo = (linemap , text_program ) if build_debuginfo else None
0 commit comments