File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 1515import re
1616
1717splitter = re .compile (r",\s*|\s+(?:,\s*)?" ).split
18+ mov_splitter = re .compile ("!|~|::" ).split
1819
1920__version__ = "0.0.0-auto.0"
2021__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PIOASM.git"
@@ -142,7 +143,20 @@ def assemble(text_program):
142143 # instr delay dst op src
143144 assembled .append (0b101_00000_000_00_000 )
144145 assembled [- 1 ] |= MOV_DESTINATIONS .index (instruction [1 ]) << 5
145- assembled [- 1 ] |= MOV_SOURCES .index (instruction [- 1 ])
146+ source = instruction [- 1 ]
147+ source_split = mov_splitter (source )
148+ if len (source_split ) == 1 :
149+ assembled [- 1 ] |= MOV_SOURCES .index (source )
150+ else :
151+ assembled [- 1 ] |= MOV_SOURCES .index (source_split [1 ])
152+ if source [:1 ] == "!" :
153+ assembled [- 1 ] |= 0x08
154+ elif source [:1 ] == "~" :
155+ assembled [- 1 ] |= 0x08
156+ elif source [:2 ] == "::" :
157+ assembled [- 1 ] |= 0x10
158+ else :
159+ raise RuntimeError ("Invalid mov operator:" , source [:1 ])
146160 if len (instruction ) > 3 :
147161 assembled [- 1 ] |= MOV_OPS .index (instruction [- 2 ]) << 3
148162 elif instruction [0 ] == "irq" :
You can’t perform that action at this time.
0 commit comments