annotate test/testthumbasm.py @ 363:396e5cefba13

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