290
|
1 #!/usr/bin/python
|
|
2
|
|
3 import unittest
|
334
|
4 from ppci.asmnodes import AInstruction, ABinop, AUnop, ASymbol, ALabel, ANumber
|
|
5 from ppci.assembler import tokenize, Assembler
|
335
|
6 from ppci.objectfile import ObjectFile
|
342
|
7 from ppci.outstream import BinaryOutputStream
|
|
8 from ppci.target import Label
|
|
9 from ppci.target.target_list import msp430target
|
290
|
10 from testasm import AsmTestCaseBase
|
|
11
|
|
12
|
342
|
13 class Msp430AssemblerTestCase(AsmTestCaseBase):
|
290
|
14 def setUp(self):
|
292
|
15 self.t = msp430target
|
335
|
16 self.obj = ObjectFile()
|
342
|
17 self.o = BinaryOutputStream(self.obj)
|
290
|
18 self.o.selectSection('.text')
|
|
19 self.a = Assembler(target=self.t, stream=self.o)
|
|
20
|
|
21 def testMov(self):
|
|
22 self.feed("mov r14, r15")
|
|
23 self.check('0F4E')
|
|
24
|
|
25 def testMov1337(self):
|
|
26 self.feed("mov 0x1337, r12")
|
|
27 self.check('3C403713')
|
|
28
|
|
29 def testAdd(self):
|
|
30 self.feed("add r15, r13")
|
|
31 self.check('0D5F')
|
|
32
|
|
33 def testReti(self):
|
|
34 self.feed("reti")
|
|
35 self.check('0013')
|
|
36
|
|
37
|
|
38 if __name__ == '__main__':
|
|
39 unittest.main()
|