view 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
line wrap: on
line source

import unittest
from ppci.outstream import BinaryOutputStream
from ppci.objectfile import ObjectFile
from asm import Assembler
from testasm import AsmTestCaseBase
from ppci.target.target_list import arm_target



class ArmAssemblerTestCase(AsmTestCaseBase):
    """ ARM-mode (not thumb-mode) instruction assembly test case """
    def setUp(self):
        self.t = arm_target
        self.obj = ObjectFile()
        self.o = BinaryOutputStream(self.obj)
        self.o.selectSection('.text')
        self.a = Assembler(target=self.t, stream=self.o)

    def testMovImm(self):
        self.feed('mov r4, 100')
        self.check('6440a0e3')

    def testAdd2(self):
        self.feed('add r12, r11, 300')
        self.check('4bcf8be2')

    def testAdd1(self):
        self.feed('add r9, r7, r2')
        self.check('029087e0')

    def testSub1(self):
        self.feed('sub r5, r6, r2')
        self.check('025046e0')

    def testSub2(self):
        self.feed('sub r0, r1, 0x80000001')
        self.check('060141e2')

    def testOrr1(self):
        self.feed('orr r8, r7, r6')
        self.check('068087e1')

    def testBranches(self):
        self.feed('b sjakie')
        self.feed('ble sjakie')
        self.feed('bgt sjakie')
        self.feed('beq sjakie')
        self.feed('bl sjakie')
        self.feed('sjakie:')
        self.feed('b sjakie')
        self.feed('ble sjakie')
        self.feed('bgt sjakie')
        self.feed('beq sjakie')
        self.feed('bl sjakie')
        self.check('030000ea 020000da 010000ca 0000000a ffffffeb feffffea fdffffda fcffffca fbffff0a faffffeb')