292
|
1 import unittest
|
342
|
2 from ppci.outstream import BinaryOutputStream
|
335
|
3 from ppci.objectfile import ObjectFile
|
292
|
4 from asm import Assembler
|
|
5 from testasm import AsmTestCaseBase
|
345
|
6 from ppci.target.target_list import arm_target
|
292
|
7
|
|
8
|
|
9
|
345
|
10 class ArmAssemblerTestCase(AsmTestCaseBase):
|
340
|
11 """ ARM-mode (not thumb-mode) instruction assembly test case """
|
|
12 def setUp(self):
|
341
|
13 self.t = arm_target
|
340
|
14 self.obj = ObjectFile()
|
342
|
15 self.o = BinaryOutputStream(self.obj)
|
340
|
16 self.o.selectSection('.text')
|
|
17 self.a = Assembler(target=self.t, stream=self.o)
|
|
18
|
|
19 def testMovImm(self):
|
|
20 self.feed('mov r4, 100')
|
|
21 self.check('6440a0e3')
|
345
|
22
|
|
23 def testAdd2(self):
|
|
24 self.feed('add r12, r11, 300')
|
|
25 self.check('4bcf8be2')
|
|
26
|
|
27 def testAdd1(self):
|
|
28 self.feed('add r9, r7, r2')
|
|
29 self.check('029087e0')
|
|
30
|
|
31 def testSub1(self):
|
|
32 self.feed('sub r5, r6, r2')
|
|
33 self.check('025046e0')
|
|
34
|
|
35 def testSub2(self):
|
|
36 self.feed('sub r0, r1, 0x80000001')
|
|
37 self.check('060141e2')
|
|
38
|
|
39 def testOrr1(self):
|
|
40 self.feed('orr r8, r7, r6')
|
|
41 self.check('068087e1')
|
|
42
|
|
43 def testBranches(self):
|
|
44 self.feed('b sjakie')
|
|
45 self.feed('ble sjakie')
|
|
46 self.feed('bgt sjakie')
|
|
47 self.feed('beq sjakie')
|
|
48 self.feed('bl sjakie')
|
|
49 self.feed('sjakie:')
|
|
50 self.feed('b sjakie')
|
|
51 self.feed('ble sjakie')
|
|
52 self.feed('bgt sjakie')
|
|
53 self.feed('beq sjakie')
|
|
54 self.feed('bl sjakie')
|
|
55 self.check('030000ea 020000da 010000ca 0000000a ffffffeb feffffea fdffffda fcffffca fbffff0a faffffeb')
|