Skip to content

Add all mov operators #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion adafruit_pioasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import re

splitter = re.compile(r",\s*|\s+(?:,\s*)?").split
mov_splitter = re.compile("!|~|::").split

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PIOASM.git"
Expand Down Expand Up @@ -142,7 +143,20 @@ def assemble(text_program):
# instr delay dst op src
assembled.append(0b101_00000_000_00_000)
assembled[-1] |= MOV_DESTINATIONS.index(instruction[1]) << 5
assembled[-1] |= MOV_SOURCES.index(instruction[-1])
source = instruction[-1]
source_split = mov_splitter(source)
if len(source_split) == 1:
assembled[-1] |= MOV_SOURCES.index(source)
else:
assembled[-1] |= MOV_SOURCES.index(source_split[1])
if source[:1] == "!":
assembled[-1] |= 0x08
elif source[:1] == "~":
assembled[-1] |= 0x08
elif source[:2] == "::":
assembled[-1] |= 0x10
else:
raise RuntimeError("Invalid mov operator:", source[:1])
if len(instruction) > 3:
assembled[-1] |= MOV_OPS.index(instruction[-2]) << 3
elif instruction[0] == "irq":
Expand Down