annotate test/testarmasm.py @ 340:c7cc54c0dfdf devel

Test featurebranch
author Windel Bouwman
date Sun, 23 Feb 2014 16:24:01 +0100
parents 582a1aaa3983
children 4d204f6f7d4e
rev   line source
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
1 import unittest
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
2 import outstream
335
582a1aaa3983 Added long branch format
Windel Bouwman
parents: 322
diff changeset
3 from ppci.objectfile import ObjectFile
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
4 from asm import Assembler
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
5 from testasm import AsmTestCaseBase
322
44f336460c2a Half of use of burg spec for arm
Windel Bouwman
parents: 292
diff changeset
6 from target.target_list import armtarget
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
7
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
8
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
9 class AssemblerArmThumb2TestCase(AsmTestCaseBase):
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
10 def setUp(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
11 self.t = armtarget
335
582a1aaa3983 Added long branch format
Windel Bouwman
parents: 322
diff changeset
12 self.obj = ObjectFile()
582a1aaa3983 Added long branch format
Windel Bouwman
parents: 322
diff changeset
13 self.o = outstream.BinaryOutputStream(self.obj)
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
14 self.o.selectSection('.text')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
15 self.a = Assembler(target=self.t, stream=self.o)
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
16
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
17 def testMapOperand(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
18 pass
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
19
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
20 def testMovImm8(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
21 self.feed('mov r4, 100')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
22 self.check('6424')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
23
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
24 @unittest.skip
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
25 def testMovExt(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
26 self.feed('mov r3, sp')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
27 self.check('')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
28
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
29 def testYield(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
30 self.feed('yield')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
31 self.check('10bf')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
32
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
33 def testPush(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
34 self.feed('push {r2,r3,lr}')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
35 self.check('0cb5')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
36
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
37 def testPop(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
38 self.feed('pop {r4-r6, pc}')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
39 self.check('70bd')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
40
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
41 def testStr5(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
42 self.feed('str r4, [r1 + 0]')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
43 self.check('0c60')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
44
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
45 def testLdr5(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
46 self.feed('ldr r4, [r0 + 0]')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
47 self.check('0468')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
48
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
49 def testLdrSpRel(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
50 self.feed('ldr r0, [sp + 4]')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
51 self.check('0198')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
52
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
53 def testStrSpRel(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
54 self.feed('str r0, [sp + 4]')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
55 self.check('0190')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
56
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
57 def testLdrPcRel(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
58 self.feed('ldr r7, henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
59 self.feed('ldr r6, henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
60 self.feed('ldr r1, henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
61 self.feed('align 4')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
62 self.feed('dcd 1')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
63 self.feed('henkie: dcd 2')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
64 self.check('024F024E 01490000 01000000 02000000')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
65
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
66 def testBranch(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
67 self.feed('start: b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
68 self.feed('beq henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
69 self.feed('bne henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
70 self.feed('henkie: b start')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
71 self.feed('eof: b eof')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
72 self.check('01e000d0 ffd1fbe7 fee7')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
73
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
74 def testConditions(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
75 self.feed('blt x')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
76 self.feed('bgt x')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
77 self.feed('x:')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
78 self.check('00dbffdc')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
79
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
80 def testBoff(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
81 self.feed('b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
82 self.feed('b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
83 self.feed('b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
84 self.feed('b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
85 self.feed('b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
86 self.feed('b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
87 self.feed('b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
88 self.feed('henkie:')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
89 self.feed('b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
90 self.feed('b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
91 self.feed('b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
92 self.feed('b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
93 self.check('05e004e0 03e002e0 01e000e0 ffe7fee7 fde7fce7 fbe7')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
94
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
95 def testBl(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
96 self.feed('bl henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
97 self.feed('bl henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
98 self.feed('henkie:')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
99 self.feed('bl henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
100 self.feed('bl henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
101 self.check('00f0 02f8 00f0 00f8 fff7 feff fff7 fcff')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
102
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
103 def testCmpRegReg(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
104 self.feed('cmp r0, r1')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
105 self.check('8842')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
106
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
107 def testAddimm3(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
108 self.feed('add r3, r5, 2')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
109 self.feed('add r4, r1, 6')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
110 self.check('ab1c8c1d')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
111
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
112 def testSubImm3(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
113 self.feed('sub r3, r5, 2')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
114 self.feed('sub r4, r1, 6')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
115 self.check('ab1e8c1f')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
116
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
117 def testLeftShift(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
118 self.feed('lsl r3, r5')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
119 self.check('ab40')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
120
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
121 def testAddSp(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
122 self.feed('add sp,sp,8')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
123 self.feed('add sp,sp,16')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
124 self.check('02b004b0')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
125
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
126 def testSubSp(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
127 self.feed('sub sp,sp,32')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
128 self.feed('sub sp,sp,4')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
129 self.check('88b081b0')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
130
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
131 def testSequence1(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
132 self.feed('mov r5, 3')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
133 self.feed('add r4, r5, 0')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
134 self.feed('loop: add r6, r4, 7')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
135 self.feed('cmp r6, 5')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
136 self.check('0325 2c1c e61d 052e')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
137
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
138 def testSequence2(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
139 self.feed('henkie:')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
140 self.feed('push {r1,r4,r5}')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
141 self.feed('add r5, r2, r4')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
142 self.feed('cmp r4, r2')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
143 self.feed('ldr r0, [sp + 4]')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
144 self.feed('str r3, [sp + 16]')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
145 self.feed('pop {r1, r4, r5}')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
146 self.feed('lsl r3, r4')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
147 self.feed('cmp r3, r5')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
148 self.feed('beq henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
149 self.feed('bne henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
150 self.feed('b henkie')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
151 self.check('32b41519 94420198 049332bc a340ab42 f6d0f5d1 f4e7')
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
152
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
153
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
154 class AssemblerArmTestCase(AsmTestCaseBase):
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
155 """ ARM-mode (not thumb-mode) instruction assembly test case """
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
156 def setUp(self):
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
157 self.t = arm_arm_target
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
158 self.obj = ObjectFile()
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
159 self.o = outstream.BinaryOutputStream(self.obj)
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
160 self.o.selectSection('.text')
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
161 self.a = Assembler(target=self.t, stream=self.o)
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
162
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
163 def testMapOperand(self):
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
164 pass
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
165
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
166 def testMovImm(self):
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
167 self.feed('mov r4, 100')
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
168 self.check('6440a0e3')