diff --git a/adafruit_pioasm.py b/adafruit_pioasm.py index a6a4ebf..81ce799 100644 --- a/adafruit_pioasm.py +++ b/adafruit_pioasm.py @@ -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: @@ -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"): @@ -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 diff --git a/tests/test_pseudo.py b/tests/test_pseudo.py new file mode 100644 index 0000000..261f03a --- /dev/null +++ b/tests/test_pseudo.py @@ -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)