annotate test/testarmasm.py @ 348:442fb043d149

Added log option to zcc
author Windel Bouwman
date Sat, 08 Mar 2014 15:32:33 +0100
parents 3bb7dcfe5529
children 13a6e73b448f
rev   line source
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
1 import unittest
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
2 from ppci.outstream import BinaryOutputStream
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
345
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
6 from ppci.target.target_list import arm_target
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
7
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
8
346
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
9 a = Assembler(arm_target)
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
10
345
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
11 class ArmAssemblerTestCase(AsmTestCaseBase):
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
12 """ ARM-mode (not thumb-mode) instruction assembly test case """
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
13 def setUp(self):
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
14 self.t = arm_target
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
15 self.obj = ObjectFile()
346
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
16 self.ostream = BinaryOutputStream(self.obj)
348
442fb043d149 Added log option to zcc
Windel Bouwman
parents: 346
diff changeset
17 self.ostream.select_section('.text')
346
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
18 self.a = a #Assembler(target=self.t)
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
19
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
20 def testMovImm(self):
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
21 self.feed('mov r4, 100')
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
22 self.check('6440a0e3')
345
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
23
346
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
24 def testMovImm2(self):
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
25 self.feed('mov sp, 0x6000')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
26 self.check('06daa0e3')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
27
345
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
28 def testAdd2(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
29 self.feed('add r12, r11, 300')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
30 self.check('4bcf8be2')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
31
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
32 def testAdd1(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
33 self.feed('add r9, r7, r2')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
34 self.check('029087e0')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
35
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
36 def testSub1(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
37 self.feed('sub r5, r6, r2')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
38 self.check('025046e0')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
39
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
40 def testSub2(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
41 self.feed('sub r0, r1, 0x80000001')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
42 self.check('060141e2')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
43
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
44 def testOrr1(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
45 self.feed('orr r8, r7, r6')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
46 self.check('068087e1')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
47
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
48 def testBranches(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
49 self.feed('b sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
50 self.feed('ble sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
51 self.feed('bgt sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
52 self.feed('beq sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
53 self.feed('bl sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
54 self.feed('sjakie:')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
55 self.feed('b sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
56 self.feed('ble sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
57 self.feed('bgt sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
58 self.feed('beq sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
59 self.feed('bl sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
60 self.check('030000ea 020000da 010000ca 0000000a ffffffeb feffffea fdffffda fcffffca fbffff0a faffffeb')
346
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
61
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
62 def testPush(self):
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
63 self.feed('push {r11,r5,r4,lr}')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
64 self.check('30482de9')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
65
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
66 def testPop(self):
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
67 self.feed('pop {r4,r5,r6}')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
68 self.check('7000bde8')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
69
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
70 def testStr(self):
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
71 self.feed('str r9, [r2, 33]')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
72 self.check('219082e5')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
73
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
74 def testLdr(self):
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
75 self.feed('ldr r5, [r3, 87]')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
76 self.check('575093e5')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
77
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
78 def testSequence1(self):
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
79 self.feed('sub r4,r5,23')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
80 self.feed('blt x')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
81 self.feed('x:')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
82 self.feed('mul r4,r5,r2')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
83 self.check('174045e2 ffffffba 950204e0')
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
84
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
85
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
86 if __name__ == '__main__':
3bb7dcfe5529 expanded arm target
Windel Bouwman
parents: 345
diff changeset
87 unittest.main()