Skip to content

Commit b379f05

Browse files
committed
Merge mov_status_count & _param into mov_status_n
.. and correct .mov_status irq prev and range handling
1 parent 86f02e8 commit b379f05

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

adafruit_pioasm.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ def __init__(self, text_program: str, *, build_debuginfo: bool = False) -> None:
6363
pio_version = 0
6464
fifo_type = None
6565
mov_status_type = None
66-
mov_status_count = None
67-
mov_status_param = None
66+
mov_status_n = None
6867
in_count = None
6968
in_shift_right = None
7069
auto_push = None
@@ -139,24 +138,26 @@ def parse_rxfifo_brackets(arg, fifo_dir):
139138
elif line.startswith(".mov_status"):
140139
require_before_instruction()
141140
required_version = 0
142-
mov_status_param = 0
141+
mov_status_n = 0
143142
mov_status_type = words[1]
144143
if words[1] in ("txfifo", "rxfifo"):
145144
if words[2] != "<":
146145
raise RuntimeError(f"Invalid {line}")
147-
mov_status_count = int_in_range(words[3], 0, 16, words[1])
146+
mov_status_n = int_in_range(words[3], 0, 32, words[1])
148147
elif words[1] == "irq":
149148
required_version = 1
150149
idx = 2
151150
if words[idx] == "next":
152-
mov_status_param = 2
151+
mov_status_n = 0x10
153152
idx += 1
154-
if words[idx] == "next":
155-
mov_status_param = 1
153+
elif words[idx] == "prev":
154+
mov_status_n = 0x8
156155
idx += 1
156+
else:
157+
mov_status_n = 0
157158
if words[idx] != "set":
158159
raise RuntimeError(f"Invalid {line})")
159-
mov_status_count = int(words[idx + 1])
160+
mov_status_n |= int_in_range(words[idx + 1], 0, 8, "mov_status irq")
160161
require_version(required_version, line)
161162
elif words[0] == ".out":
162163
require_before_instruction()
@@ -447,8 +448,7 @@ def parse_rxfifo_brackets(arg, fifo_dir):
447448

448449
if mov_status_type is not None:
449450
self.pio_kwargs["mov_status_type"] = mov_status_type
450-
self.pio_kwargs["mov_status_count"] = mov_status_count
451-
self.pio_kwargs["mov_status_param"] = mov_status_param
451+
self.pio_kwargs["mov_status_n"] = mov_status_n
452452

453453
if set_count not in (None, 32):
454454
self.pio_kwargs["set_count"] = set_count

tests/test_version.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,39 @@ def test_mov_status() -> None:
3232
".mov_status txfifo < 5",
3333
sideset_enable=0,
3434
mov_status_type="txfifo",
35-
mov_status_count=5,
36-
mov_status_param=0,
35+
mov_status_n=5,
3736
)
3837
assert_pio_kwargs(
3938
".mov_status rxfifo < 8",
4039
sideset_enable=0,
4140
mov_status_type="rxfifo",
42-
mov_status_count=8,
43-
mov_status_param=0,
41+
mov_status_n=8,
4442
)
4543
assert_assembly_fails(".mov_status rxfifo < -1")
46-
assert_assembly_fails(".mov_status rxfifo < 16")
44+
assert_assembly_fails(".mov_status rxfifo < 33")
4745
assert_assembly_fails(".mov_status irq next set 3")
46+
assert_pio_kwargs(
47+
".pio_version 1\n.mov_status irq prev set 3",
48+
pio_version=1,
49+
sideset_enable=0,
50+
mov_status_type="irq",
51+
mov_status_n=3 | 0x8,
52+
)
4853
assert_pio_kwargs(
4954
".pio_version 1\n.mov_status irq next set 3",
5055
pio_version=1,
5156
sideset_enable=0,
5257
mov_status_type="irq",
53-
mov_status_count=3,
54-
mov_status_param=2,
58+
mov_status_n=3 | 0x10,
5559
)
5660
assert_pio_kwargs(
5761
".pio_version 1\n.mov_status irq set 3",
5862
pio_version=1,
5963
sideset_enable=0,
6064
mov_status_type="irq",
61-
mov_status_count=3,
62-
mov_status_param=0,
65+
mov_status_n=3,
6366
)
67+
assert_assembly_fails(".pio_version 1\n.mov_status irq prev set 9")
6468

6569

6670
def test_dot_in() -> None:

0 commit comments

Comments
 (0)