Skip to content

Commit 3bacee4

Browse files
committed
support .offset pseudo-op
1 parent 718dd13 commit 3bacee4

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

adafruit_pioasm.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
5252
sideset_enable = 0
5353
wrap = None
5454
wrap_target = None
55+
offset = -1
5556
for i, line in enumerate(text_program.split("\n")):
5657
line = line.strip()
5758
if not line:
@@ -62,6 +63,8 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
6263
if program_name:
6364
raise RuntimeError("Multiple programs not supported")
6465
program_name = line.split()[1]
66+
elif line.startswith(".offset"):
67+
offset = int(line.split()[1], 0)
6568
elif line.startswith(".wrap_target"):
6669
wrap_target = len(instructions)
6770
elif line.startswith(".wrap"):
@@ -227,6 +230,9 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
227230
"sideset_enable": sideset_enable,
228231
}
229232

233+
if offset != -1:
234+
self.pio_kwargs["offset"] = offset
235+
230236
if sideset_count != 0:
231237
self.pio_kwargs["sideset_pin_count"] = sideset_count
232238

tests/test_pseudo.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: 2021 Jeff Epler, written for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
"""
6+
Tests pseudo-ops
7+
"""
8+
9+
from pytest_helpers import assert_pio_kwargs
10+
11+
12+
def test_offset():
13+
assert_pio_kwargs(".offset 7", offset=7, sideset_enable=False)

0 commit comments

Comments
 (0)