diff --git a/adafruit_pioasm.py b/adafruit_pioasm.py index 1ddcb1b..3b83347 100644 --- a/adafruit_pioasm.py +++ b/adafruit_pioasm.py @@ -63,8 +63,7 @@ def __init__(self, text_program: str, *, build_debuginfo: bool = False) -> None: pio_version = 0 fifo_type = None mov_status_type = None - mov_status_count = None - mov_status_param = None + mov_status_n = None in_count = None in_shift_right = None auto_push = None @@ -139,24 +138,26 @@ def parse_rxfifo_brackets(arg, fifo_dir): elif line.startswith(".mov_status"): require_before_instruction() required_version = 0 - mov_status_param = 0 + mov_status_n = 0 mov_status_type = words[1] if words[1] in ("txfifo", "rxfifo"): if words[2] != "<": raise RuntimeError(f"Invalid {line}") - mov_status_count = int_in_range(words[3], 0, 16, words[1]) + mov_status_n = int_in_range(words[3], 0, 32, words[1]) elif words[1] == "irq": required_version = 1 idx = 2 if words[idx] == "next": - mov_status_param = 2 + mov_status_n = 0x10 idx += 1 - if words[idx] == "next": - mov_status_param = 1 + elif words[idx] == "prev": + mov_status_n = 0x8 idx += 1 + else: + mov_status_n = 0 if words[idx] != "set": raise RuntimeError(f"Invalid {line})") - mov_status_count = int(words[idx + 1]) + mov_status_n |= int_in_range(words[idx + 1], 0, 8, "mov_status irq") require_version(required_version, line) elif words[0] == ".out": require_before_instruction() @@ -447,8 +448,7 @@ def parse_rxfifo_brackets(arg, fifo_dir): if mov_status_type is not None: self.pio_kwargs["mov_status_type"] = mov_status_type - self.pio_kwargs["mov_status_count"] = mov_status_count - self.pio_kwargs["mov_status_param"] = mov_status_param + self.pio_kwargs["mov_status_n"] = mov_status_n if set_count not in (None, 32): self.pio_kwargs["set_count"] = set_count diff --git a/tests/test_version.py b/tests/test_version.py index 380d5aa..cf015a6 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -32,35 +32,39 @@ def test_mov_status() -> None: ".mov_status txfifo < 5", sideset_enable=0, mov_status_type="txfifo", - mov_status_count=5, - mov_status_param=0, + mov_status_n=5, ) assert_pio_kwargs( ".mov_status rxfifo < 8", sideset_enable=0, mov_status_type="rxfifo", - mov_status_count=8, - mov_status_param=0, + mov_status_n=8, ) assert_assembly_fails(".mov_status rxfifo < -1") - assert_assembly_fails(".mov_status rxfifo < 16") + assert_assembly_fails(".mov_status rxfifo < 33") assert_assembly_fails(".mov_status irq next set 3") + assert_pio_kwargs( + ".pio_version 1\n.mov_status irq prev set 3", + pio_version=1, + sideset_enable=0, + mov_status_type="irq", + mov_status_n=3 | 0x8, + ) assert_pio_kwargs( ".pio_version 1\n.mov_status irq next set 3", pio_version=1, sideset_enable=0, mov_status_type="irq", - mov_status_count=3, - mov_status_param=2, + mov_status_n=3 | 0x10, ) assert_pio_kwargs( ".pio_version 1\n.mov_status irq set 3", pio_version=1, sideset_enable=0, mov_status_type="irq", - mov_status_count=3, - mov_status_param=0, + mov_status_n=3, ) + assert_assembly_fails(".pio_version 1\n.mov_status irq prev set 9") def test_dot_in() -> None: