Mercurial > lcfOS
comparison test/testarmasm.py @ 292:534b94b40aa8
Fixup reorganize
author | Windel Bouwman |
---|---|
date | Wed, 27 Nov 2013 08:06:42 +0100 |
parents | |
children | 44f336460c2a |
comparison
equal
deleted
inserted
replaced
290:7b38782ed496 | 292:534b94b40aa8 |
---|---|
1 import unittest | |
2 import outstream | |
3 from asm import Assembler | |
4 from testasm import AsmTestCaseBase | |
5 from target import armtarget | |
6 | |
7 | |
8 class AssemblerARMTestCase(AsmTestCaseBase): | |
9 def setUp(self): | |
10 self.t = armtarget | |
11 self.o = outstream.BinOutputStream() | |
12 self.o.selectSection('.text') | |
13 self.a = Assembler(target=self.t, stream=self.o) | |
14 | |
15 def testMapOperand(self): | |
16 pass | |
17 | |
18 def testMovImm8(self): | |
19 self.feed('mov r4, 100') | |
20 self.check('6424') | |
21 | |
22 @unittest.skip | |
23 def testMovExt(self): | |
24 self.feed('mov r3, sp') | |
25 self.check('') | |
26 | |
27 def testYield(self): | |
28 self.feed('yield') | |
29 self.check('10bf') | |
30 | |
31 def testPush(self): | |
32 self.feed('push {r2,r3,lr}') | |
33 self.check('0cb5') | |
34 | |
35 def testPop(self): | |
36 self.feed('pop {r4-r6, pc}') | |
37 self.check('70bd') | |
38 | |
39 def testStr5(self): | |
40 self.feed('str r4, [r1 + 0]') | |
41 self.check('0c60') | |
42 | |
43 def testLdr5(self): | |
44 self.feed('ldr r4, [r0 + 0]') | |
45 self.check('0468') | |
46 | |
47 def testLdrSpRel(self): | |
48 self.feed('ldr r0, [sp + 4]') | |
49 self.check('0198') | |
50 | |
51 def testStrSpRel(self): | |
52 self.feed('str r0, [sp + 4]') | |
53 self.check('0190') | |
54 | |
55 def testLdrPcRel(self): | |
56 self.feed('ldr r7, henkie') | |
57 self.feed('ldr r6, henkie') | |
58 self.feed('ldr r1, henkie') | |
59 self.feed('align 4') | |
60 self.feed('dcd 1') | |
61 self.feed('henkie: dcd 2') | |
62 self.check('024F024E 01490000 01000000 02000000') | |
63 | |
64 def testBranch(self): | |
65 self.feed('start: b henkie') | |
66 self.feed('beq henkie') | |
67 self.feed('bne henkie') | |
68 self.feed('henkie: b start') | |
69 self.feed('eof: b eof') | |
70 self.check('01e000d0 ffd1fbe7 fee7') | |
71 | |
72 def testConditions(self): | |
73 self.feed('blt x') | |
74 self.feed('bgt x') | |
75 self.feed('x:') | |
76 self.check('00dbffdc') | |
77 | |
78 def testBoff(self): | |
79 self.feed('b henkie') | |
80 self.feed('b henkie') | |
81 self.feed('b henkie') | |
82 self.feed('b henkie') | |
83 self.feed('b henkie') | |
84 self.feed('b henkie') | |
85 self.feed('b henkie') | |
86 self.feed('henkie:') | |
87 self.feed('b henkie') | |
88 self.feed('b henkie') | |
89 self.feed('b henkie') | |
90 self.feed('b henkie') | |
91 self.check('05e004e0 03e002e0 01e000e0 ffe7fee7 fde7fce7 fbe7') | |
92 | |
93 def testBl(self): | |
94 self.feed('bl henkie') | |
95 self.feed('bl henkie') | |
96 self.feed('henkie:') | |
97 self.feed('bl henkie') | |
98 self.feed('bl henkie') | |
99 self.check('00f0 02f8 00f0 00f8 fff7 feff fff7 fcff') | |
100 | |
101 def testCmpRegReg(self): | |
102 self.feed('cmp r0, r1') | |
103 self.check('8842') | |
104 | |
105 def testAddimm3(self): | |
106 self.feed('add r3, r5, 2') | |
107 self.feed('add r4, r1, 6') | |
108 self.check('ab1c8c1d') | |
109 | |
110 def testSubImm3(self): | |
111 self.feed('sub r3, r5, 2') | |
112 self.feed('sub r4, r1, 6') | |
113 self.check('ab1e8c1f') | |
114 | |
115 def testLeftShift(self): | |
116 self.feed('lsl r3, r5') | |
117 self.check('ab40') | |
118 | |
119 def testAddSp(self): | |
120 self.feed('add sp,sp,8') | |
121 self.feed('add sp,sp,16') | |
122 self.check('02b004b0') | |
123 | |
124 def testSubSp(self): | |
125 self.feed('sub sp,sp,32') | |
126 self.feed('sub sp,sp,4') | |
127 self.check('88b081b0') | |
128 | |
129 def testSequence1(self): | |
130 self.feed('mov r5, 3') | |
131 self.feed('add r4, r5, 0') | |
132 self.feed('loop: add r6, r4, 7') | |
133 self.feed('cmp r6, 5') | |
134 self.check('0325 2c1c e61d 052e') | |
135 | |
136 def testSequence2(self): | |
137 self.feed('henkie:') | |
138 self.feed('push {r1,r4,r5}') | |
139 self.feed('add r5, r2, r4') | |
140 self.feed('cmp r4, r2') | |
141 self.feed('ldr r0, [sp + 4]') | |
142 self.feed('str r3, [sp + 16]') | |
143 self.feed('pop {r1, r4, r5}') | |
144 self.feed('lsl r3, r4') | |
145 self.feed('cmp r3, r5') | |
146 self.feed('beq henkie') | |
147 self.feed('bne henkie') | |
148 self.feed('b henkie') | |
149 self.check('32b41519 94420198 049332bc a340ab42 f6d0f5d1 f4e7') |