annotate test/testmsp430asm.py @ 339:6ee17c4dd6b8

Increase timeout
author Windel Bouwman
date Fri, 21 Feb 2014 13:35:07 +0100
parents 582a1aaa3983
children 4d204f6f7d4e
rev   line source
290
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
1 #!/usr/bin/python
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
2
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
3 import unittest
334
6f4753202b9a Added more recipes
Windel Bouwman
parents: 322
diff changeset
4 from ppci.asmnodes import AInstruction, ABinop, AUnop, ASymbol, ALabel, ANumber
6f4753202b9a Added more recipes
Windel Bouwman
parents: 322
diff changeset
5 from ppci.assembler import tokenize, Assembler
335
582a1aaa3983 Added long branch format
Windel Bouwman
parents: 334
diff changeset
6 from ppci.objectfile import ObjectFile
290
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
7 import outstream
322
44f336460c2a Half of use of burg spec for arm
Windel Bouwman
parents: 292
diff changeset
8 from target import Label
44f336460c2a Half of use of burg spec for arm
Windel Bouwman
parents: 292
diff changeset
9 from target.target_list import msp430target
290
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
10 from testasm import AsmTestCaseBase
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
11
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
12
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
13 class AssemblerMSP430TestCase(AsmTestCaseBase):
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
14 def setUp(self):
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
15 self.t = msp430target
335
582a1aaa3983 Added long branch format
Windel Bouwman
parents: 334
diff changeset
16 self.obj = ObjectFile()
582a1aaa3983 Added long branch format
Windel Bouwman
parents: 334
diff changeset
17 self.o = outstream.BinaryOutputStream(self.obj)
290
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
18 self.o.selectSection('.text')
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
19 self.a = Assembler(target=self.t, stream=self.o)
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
20
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
21 def testMapMovInstruction(self):
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
22 i = AInstruction('mov', [ASymbol('r14'), ASymbol('r15')])
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
23 ri = self.t.mapInstruction(i)
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
24
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
25 def testMapRetiInstruction(self):
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
26 i = AInstruction('reti', [])
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
27 ri = self.t.mapInstruction(i)
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
28
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
29 def testMov(self):
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
30 self.feed("mov r14, r15")
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
31 self.check('0F4E')
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
32
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
33 def testMov1337(self):
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
34 self.feed("mov 0x1337, r12")
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
35 self.check('3C403713')
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
36
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
37 def testAdd(self):
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
38 self.feed("add r15, r13")
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
39 self.check('0D5F')
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
40
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
41 def testReti(self):
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
42 self.feed("reti")
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
43 self.check('0013')
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
44
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
45 def testMSPinstructionCount(self):
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
46 """ Check that there are 27 instructions """
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
47 self.assertEqual(27, len(self.t.instructions))
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
48
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
49
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
50 if __name__ == '__main__':
7b38782ed496 File moves
Windel Bouwman
parents:
diff changeset
51 unittest.main()