comparison test/testmsp430asm.py @ 290:7b38782ed496

File moves
author Windel Bouwman
date Sun, 24 Nov 2013 11:24:15 +0100
parents
children 534b94b40aa8
comparison
equal deleted inserted replaced
289:bd2593de3ff8 290:7b38782ed496
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 msp430
7 import outstream
8 from target import Label
9 from testasm import AsmTestCaseBase
10
11
12 class AssemblerMSP430TestCase(AsmTestCaseBase):
13 def setUp(self):
14 self.t = msp430.msp430target
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()