annotate test/testarmasm.py @ 345:b4882ff0ed06

Added more arm isa tests
author Windel Bouwman
date Sun, 02 Mar 2014 17:12:08 +0100
parents 86b02c98a717
children 3bb7dcfe5529
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
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents:
diff changeset
9
345
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
10 class ArmAssemblerTestCase(AsmTestCaseBase):
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
11 """ ARM-mode (not thumb-mode) instruction assembly test case """
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
12 def setUp(self):
341
4d204f6f7d4e Rewrite of assembler parts
Windel Bouwman
parents: 340
diff changeset
13 self.t = arm_target
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
14 self.obj = ObjectFile()
342
86b02c98a717 Moved target directory
Windel Bouwman
parents: 341
diff changeset
15 self.o = BinaryOutputStream(self.obj)
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
16 self.o.selectSection('.text')
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
17 self.a = Assembler(target=self.t, stream=self.o)
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
18
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
19 def testMovImm(self):
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
20 self.feed('mov r4, 100')
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents: 335
diff changeset
21 self.check('6440a0e3')
345
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
22
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
23 def testAdd2(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
24 self.feed('add r12, r11, 300')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
25 self.check('4bcf8be2')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
26
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
27 def testAdd1(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
28 self.feed('add r9, r7, r2')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
29 self.check('029087e0')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
30
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
31 def testSub1(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
32 self.feed('sub r5, r6, r2')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
33 self.check('025046e0')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
34
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
35 def testSub2(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
36 self.feed('sub r0, r1, 0x80000001')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
37 self.check('060141e2')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
38
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
39 def testOrr1(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
40 self.feed('orr r8, r7, r6')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
41 self.check('068087e1')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
42
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
43 def testBranches(self):
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
44 self.feed('b sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
45 self.feed('ble sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
46 self.feed('bgt sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
47 self.feed('beq sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
48 self.feed('bl sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
49 self.feed('sjakie:')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
50 self.feed('b sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
51 self.feed('ble sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
52 self.feed('bgt sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
53 self.feed('beq sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
54 self.feed('bl sjakie')
b4882ff0ed06 Added more arm isa tests
Windel Bouwman
parents: 342
diff changeset
55 self.check('030000ea 020000da 010000ca 0000000a ffffffeb feffffea fdffffda fcffffca fbffff0a faffffeb')