diff --git a/adafruit_pioasm.py b/adafruit_pioasm.py index 81ce799..f6762ea 100644 --- a/adafruit_pioasm.py +++ b/adafruit_pioasm.py @@ -46,6 +46,7 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None: assembled = [] program_name = None labels = {} + public_labels = {} linemap = [] instructions = [] sideset_count = 0 @@ -79,6 +80,10 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None: if label in labels: raise SyntaxError(f"Duplicate label {repr(label)}") labels[label] = len(instructions) + if line.startswith("public "): + public_labels[(line.split("public ")[1]).split(":")[0]] = len( + instructions + ) elif line: # Only add as an instruction if the line isn't empty instructions.append(line) @@ -241,6 +246,9 @@ def __init__(self, text_program: str, *, build_debuginfo=False) -> None: if wrap_target is not None: self.pio_kwargs["wrap_target"] = wrap_target + if public_labels: + self.pio_kwargs["public_labels"] = public_labels + self.assembled = array.array("H", assembled) if build_debuginfo: