Skip to content

Commit

Permalink
Improve error handling of origin & mov_status directives
Browse files Browse the repository at this point in the history
  • Loading branch information
jepler committed Sep 5, 2024
1 parent 4deafa6 commit 5659a26
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions adafruit_pioasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def int_in_range(arg, low, high, what, radix=0):
pio_version = int_in_range(words[1], 0, 2, ".pio_version")
elif line.startswith(".origin"):
require_before_instruction()
offset = int(line.split()[1], 0)
offset = int_in_range(words[1], 0, 32, ".origin")
elif line.startswith(".wrap_target"):
wrap_target = len(instructions)
elif line.startswith(".wrap"):
Expand All @@ -126,7 +126,7 @@ def int_in_range(arg, low, high, what, radix=0):
if words[1] in ("txfifo", "rxfifo"):
if words[2] != "<":
raise RuntimeError(f"Invalid {line}")
mov_status_count = int(words[3])
mov_status_count = int_in_range(words[3], 0, 16, words[1])
elif words[1] == "irq":
required_version = 1
idx = 2
Expand All @@ -139,9 +139,6 @@ def int_in_range(arg, low, high, what, radix=0):
if words[idx] != "set":
raise RuntimeError(f"Invalid {line})")
mov_status_count = int(words[idx + 1])

if not 0 <= mov_status_count < 16:
raise RuntimeError(f"Invalid mov_status count {mov_status_count}")
require_version(required_version, line)
elif words[0] == ".in":
require_before_instruction()
Expand Down

0 comments on commit 5659a26

Please sign in to comment.