Skip to content

Commit

Permalink
Merge pull request #59 from jepler/offset-pseudo
Browse files Browse the repository at this point in the history
support .offset pseudo-op
  • Loading branch information
tannewt authored Aug 7, 2023
2 parents 718dd13 + 3bacee4 commit 7ec05cd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions adafruit_pioasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
sideset_enable = 0
wrap = None
wrap_target = None
offset = -1
for i, line in enumerate(text_program.split("\n")):
line = line.strip()
if not line:
Expand All @@ -62,6 +63,8 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
if program_name:
raise RuntimeError("Multiple programs not supported")
program_name = line.split()[1]
elif line.startswith(".offset"):
offset = int(line.split()[1], 0)
elif line.startswith(".wrap_target"):
wrap_target = len(instructions)
elif line.startswith(".wrap"):
Expand Down Expand Up @@ -227,6 +230,9 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None:
"sideset_enable": sideset_enable,
}

if offset != -1:
self.pio_kwargs["offset"] = offset

if sideset_count != 0:
self.pio_kwargs["sideset_pin_count"] = sideset_count

Expand Down
13 changes: 13 additions & 0 deletions tests/test_pseudo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2021 Jeff Epler, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT

"""
Tests pseudo-ops
"""

from pytest_helpers import assert_pio_kwargs


def test_offset():
assert_pio_kwargs(".offset 7", offset=7, sideset_enable=False)

0 comments on commit 7ec05cd

Please sign in to comment.