annotate test/testthumbasm.py @ 389:2ec730e45ea1

Added check for recursive struct
author Windel Bouwman
date Fri, 16 May 2014 12:29:31 +0200
parents d056b552d3f4
children
rev   line source
345
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
1 import unittest
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
2 from ppci.outstream import BinaryOutputStream
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
3 from ppci.objectfile import ObjectFile
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
4 from testasm import AsmTestCaseBase
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
5 from ppci.target.target_list import thumb_target
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
6
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
7
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
8 class ThumbAssemblerTestCase(AsmTestCaseBase):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
9 def setUp(self):
385
d056b552d3f4 Made better use of layout
Windel Bouwman
parents: 383
diff changeset
10 self.target = thumb_target
345
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
11 self.obj = ObjectFile()
346
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
12 self.ostream = BinaryOutputStream(self.obj)
383
173e20a47fda Added linker description loader
Windel Bouwman
parents: 381
diff changeset
13 self.ostream.select_section('code')
381
6df89163e114 Fix section and ldr pseudo instruction
Windel Bouwman
parents: 348
diff changeset
14 self.assembler = thumb_target.assembler
345
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
15
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
16 def testMovImm8(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
17 self.feed('mov r4, 100')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
18 self.check('6424')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
19
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
20 @unittest.skip
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
21 def testMovExt(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
22 self.feed('mov r3, sp')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
23 self.check('')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
24
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
25 def testYield(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
26 self.feed('yield')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
27 self.check('10bf')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
28
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
29 def testPush(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
30 self.feed('push {r2,r3,lr}')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
31 self.check('0cb5')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
32
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
33 def testPop(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
34 self.feed('pop {r4-r6, pc}')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
35 self.check('70bd')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
36
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
37 def testStr5(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
38 self.feed('str r4, [r1 + 0]')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
39 self.check('0c60')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
40
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
41 def testLdr5(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
42 self.feed('ldr r4, [r0 + 0]')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
43 self.check('0468')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
44
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
45 def testLdrSpRel(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
46 self.feed('ldr r0, [sp + 4]')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
47 self.check('0198')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
48
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
49 def testStrSpRel(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
50 self.feed('str r0, [sp + 4]')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
51 self.check('0190')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
52
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
53 def testLdrPcRel(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
54 self.feed('ldr r7, henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
55 self.feed('ldr r6, henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
56 self.feed('ldr r1, henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
57 self.feed('align 4')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
58 self.feed('dcd 1')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
59 self.feed('henkie: dcd 2')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
60 self.check('024F024E 01490000 01000000 02000000')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
61
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
62 def testBranch(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
63 self.feed('start: b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
64 self.feed('beq henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
65 self.feed('bne henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
66 self.feed('henkie: b start')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
67 self.feed('eof: b eof')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
68 self.check('01e000d0 ffd1fbe7 fee7')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
69
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
70 def testConditions(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
71 self.feed('blt x')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
72 self.feed('bgt x')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
73 self.feed('x:')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
74 self.check('00dbffdc')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
75
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
76 def testBoff(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
77 self.feed('b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
78 self.feed('b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
79 self.feed('b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
80 self.feed('b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
81 self.feed('b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
82 self.feed('b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
83 self.feed('b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
84 self.feed('henkie:')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
85 self.feed('b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
86 self.feed('b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
87 self.feed('b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
88 self.feed('b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
89 self.check('05e004e0 03e002e0 01e000e0 ffe7fee7 fde7fce7 fbe7')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
90
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
91 def testBl(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
92 self.feed('bl henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
93 self.feed('bl henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
94 self.feed('henkie:')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
95 self.feed('bl henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
96 self.feed('bl henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
97 self.check('00f0 02f8 00f0 00f8 fff7 feff fff7 fcff')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
98
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
99 def testCmpRegReg(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
100 self.feed('cmp r0, r1')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
101 self.check('8842')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
102
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
103 def testAddimm3(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
104 self.feed('add r3, r5, 2')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
105 self.feed('add r4, r1, 6')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
106 self.check('ab1c8c1d')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
107
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
108 def testSubImm3(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
109 self.feed('sub r3, r5, 2')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
110 self.feed('sub r4, r1, 6')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
111 self.check('ab1e8c1f')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
112
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
113 def testLeftShift(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
114 self.feed('lsl r3, r5')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
115 self.check('ab40')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
116
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
117 def testAddSp(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
118 self.feed('add sp,sp,8')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
119 self.feed('add sp,sp,16')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
120 self.check('02b004b0')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
121
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
122 def testSubSp(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
123 self.feed('sub sp,sp,32')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
124 self.feed('sub sp,sp,4')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
125 self.check('88b081b0')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
126
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
127 def testSequence1(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
128 self.feed('mov r5, 3')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
129 self.feed('add r4, r5, 0')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
130 self.feed('loop: add r6, r4, 7')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
131 self.feed('cmp r6, 5')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
132 self.check('0325 2c1c e61d 052e')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
133
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
134 def testSequence2(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
135 self.feed('henkie:')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
136 self.feed('push {r1,r4,r5}')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
137 self.feed('add r5, r2, r4')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
138 self.feed('cmp r4, r2')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
139 self.feed('ldr r0, [sp + 4]')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
140 self.feed('str r3, [sp + 16]')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
141 self.feed('pop {r1, r4, r5}')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
142 self.feed('lsl r3, r4')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
143 self.feed('cmp r3, r5')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
144 self.feed('beq henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
145 self.feed('bne henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
146 self.feed('b henkie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
147 self.check('32b41519 94420198 049332bc a340ab42 f6d0f5d1 f4e7')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents:
diff changeset
148