Skip to content

Commit fbafe00

Browse files
authored
Merge pull request #34 from dannystaple/mov_operators
Turns out, this dialect supports taking out spaces and the bang mark.
2 parents 15e45fb + c3fa9b6 commit fbafe00

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

tests/testpioasm.py

+23-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def nice_opcode(o):
1818
return o[:3] + "_" + o[3:8] + "_" + o[8:]
1919

2020

21-
class TestNop(unittest.TestCase):
21+
class AssembleChecks(unittest.TestCase):
2222
def assertAssemblesTo(self, source, expected):
2323
actual = adafruit_pioasm.assemble(source)
2424
expected_bin = [nice_opcode(x) for x in expected]
@@ -35,6 +35,8 @@ def assertAssemblyFails(self, source, match=None, errtype=RuntimeError):
3535
else:
3636
self.assertRaises(errtype, adafruit_pioasm.assemble, source)
3737

38+
39+
class TestNop(AssembleChecks):
3840
def testNonsense(self):
3941
self.assertAssemblyFails("nope")
4042

@@ -55,12 +57,6 @@ def testSidesetOpt(self):
5557
)
5658
self.assertAssemblesTo(".side_set 1 opt\nnop [1]", [0b101_00001_010_00_010])
5759

58-
def testMov(self):
59-
# non happy path
60-
self.assertAssemblyFails(
61-
"mov x, blah", match="Invalid mov source 'blah'", errtype=ValueError
62-
)
63-
6460
def testSet(self):
6561
# non happy path
6662
self.assertAssemblyFails(
@@ -94,3 +90,23 @@ def testWait(self):
9490
self.assertAssemblesTo("wait 0 irq 0 rel", [0b001_00000_0_10_10000])
9591
self.assertAssemblesTo("wait 1 irq 0", [0b001_00000_1_10_00000])
9692
self.assertAssemblesTo("wait 0 irq 1 rel", [0b001_00000_0_10_10001])
93+
94+
95+
class TestMov(AssembleChecks):
96+
def testMovNonHappy(self):
97+
# non happy path
98+
self.assertAssemblyFails(
99+
"mov x, blah", match="Invalid mov source 'blah'", errtype=ValueError
100+
)
101+
102+
def testMovInvert(self):
103+
# test moving and inverting
104+
self.assertAssemblesTo("mov x, ~ x", [0b101_00000_001_01_001])
105+
self.assertAssemblesTo("mov x, ~ x", [0b101_00000_001_01_001])
106+
self.assertAssemblesTo("mov x, ~x", [0b101_00000_001_01_001])
107+
self.assertAssemblesTo("mov x, !x", [0b101_00000_001_01_001])
108+
109+
def testMovReverse(self):
110+
# test moving and reversing bits
111+
self.assertAssemblesTo("mov x, :: x", [0b101_00000_001_10_001])
112+
self.assertAssemblesTo("mov x, ::x", [0b101_00000_001_10_001])

0 commit comments

Comments
 (0)