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