Skip to content

Commit 7acebc6

Browse files
committed
Add mov pindirs
1 parent 895f8eb commit 7acebc6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

adafruit_pioasm.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
IN_SOURCES = ["pins", "x", "y", "null", None, None, "isr", "osr"]
3030
OUT_DESTINATIONS = ["pins", "x", "y", "null", "pindirs", "pc", "isr", "exec"]
3131
WAIT_SOURCES = ["gpio", "pin", "irq", None]
32-
MOV_DESTINATIONS = ["pins", "x", "y", None, "exec", "pc", "isr", "osr"]
32+
MOV_DESTINATIONS_V0 = ["pins", "x", "y", None, "exec", "pc", "isr", "osr"]
33+
MOV_DESTINATIONS_V1 = ["pins", "x", "y", "pindirs", "exec", "pc", "isr", "osr"]
3334
MOV_SOURCES = ["pins", "x", "y", "null", None, "status", "isr", "osr"]
3435
MOV_OPS = [None, "~", "::", None]
3536
SET_DESTINATIONS = ["pins", "x", "y", None, "pindirs", None, None, None]
@@ -219,6 +220,11 @@ def parse_rxfifo_brackets(arg, fifo_dir):
219220
instructions.append(line)
220221
linemap.append(i)
221222

223+
if pio_version >= 1:
224+
mov_destinations = MOV_DESTINATIONS_V1
225+
else:
226+
mov_destinations = MOV_DESTINATIONS_V0
227+
222228
max_delay = 2 ** (5 - sideset_count - sideset_enable) - 1
223229
assembled = []
224230
for line in instructions:
@@ -331,7 +337,7 @@ def parse_rxfifo_brackets(arg, fifo_dir):
331337
assembled[-1] |= parse_rxfifo_brackets(instruction[2], "get")
332338
else:
333339
assembled.append(0b101_00000_000_00_000)
334-
assembled[-1] |= MOV_DESTINATIONS.index(instruction[1]) << 5
340+
assembled[-1] |= mov_destinations.index(instruction[1]) << 5
335341
source = instruction[-1]
336342
source_split = mov_splitter(source)
337343
if len(source_split) == 1:

tests/test_version.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,6 @@ def test_mov_v1() -> None:
122122
assert_assembly_fails(prefix + "mov osr, rxfifo[8]")
123123
assert_assembles_to(prefix + "mov rxfifo[y], isr", [0b100_00000_0001_1_000])
124124
assert_assembles_to(prefix + "mov osr, rxfifo[1]", [0b100_00000_1001_0_001])
125+
126+
assert_assembly_fails("mov pindirs, null", errtype=ValueError)
127+
assert_assembles_to(prefix + "mov pindirs, null", [0b101_00000_01100011])

0 commit comments

Comments
 (0)