290
|
1 #!/usr/bin/python
|
|
2
|
|
3 import unittest
|
|
4 from asmnodes import AInstruction, ABinop, AUnop, ASymbol, ALabel, ANumber
|
|
5 from asm import tokenize, Assembler
|
|
6 import outstream
|
292
|
7 from target import Label, msp430target
|
290
|
8 from testasm import AsmTestCaseBase
|
|
9
|
|
10
|
|
11 class AssemblerMSP430TestCase(AsmTestCaseBase):
|
|
12 def setUp(self):
|
292
|
13 self.t = msp430target
|
290
|
14 self.o = outstream.BinOutputStream()
|
|
15 self.o.selectSection('.text')
|
|
16 self.a = Assembler(target=self.t, stream=self.o)
|
|
17
|
|
18 def testMapMovInstruction(self):
|
|
19 i = AInstruction('mov', [ASymbol('r14'), ASymbol('r15')])
|
|
20 ri = self.t.mapInstruction(i)
|
|
21
|
|
22 def testMapRetiInstruction(self):
|
|
23 i = AInstruction('reti', [])
|
|
24 ri = self.t.mapInstruction(i)
|
|
25
|
|
26 def testMov(self):
|
|
27 self.feed("mov r14, r15")
|
|
28 self.check('0F4E')
|
|
29
|
|
30 def testMov1337(self):
|
|
31 self.feed("mov 0x1337, r12")
|
|
32 self.check('3C403713')
|
|
33
|
|
34 def testAdd(self):
|
|
35 self.feed("add r15, r13")
|
|
36 self.check('0D5F')
|
|
37
|
|
38 def testReti(self):
|
|
39 self.feed("reti")
|
|
40 self.check('0013')
|
|
41
|
|
42 def testMSPinstructionCount(self):
|
|
43 """ Check that there are 27 instructions """
|
|
44 self.assertEqual(27, len(self.t.instructions))
|
|
45
|
|
46
|
|
47 if __name__ == '__main__':
|
|
48 unittest.main()
|