Mercurial > lcfOS
diff python/testasm.py @ 202:f22b431f4113
Added arm add instruction
author | Windel Bouwman |
---|---|
date | Sat, 15 Jun 2013 10:02:50 +0200 |
parents | d5debbfc0200 |
children | ca1ea402f6a1 |
line wrap: on
line diff
--- a/python/testasm.py Thu Jun 13 00:07:28 2013 +0200 +++ b/python/testasm.py Sat Jun 15 10:02:50 2013 +0200 @@ -5,6 +5,7 @@ from asmnodes import AInstruction, ABinop, AUnop, ASymbol, ALabel, ANumber from asm import tokenize, Assembler import msp430 +import arm_cm3 class AssemblerLexingCase(unittest.TestCase): """ Tests the assemblers lexer """ @@ -130,12 +131,12 @@ def testMov1337(self): line1 = "mov 0x1337, r12" self.a.assemble_line(line1) - self.assertEqual(bytes([0x3C, 0x40, 0x37, 0x13]), self.a.binout) + self.assertEqual(bytes.fromhex('3C403713'), self.a.binout) def testAdd(self): line1 = "add r15, r13" self.a.assemble_line(line1) - self.assertEqual(bytes([0x0D, 0x5F]), self.a.binout) + self.assertEqual(bytes.fromhex('0D5F'), self.a.binout) def testReti(self): line1 = "reti" @@ -147,6 +148,23 @@ self.assertEqual(27, len(self.t.instructions)) +class AssemblerARMTestCase(unittest.TestCase): + def setUp(self): + self.t = arm_cm3.armtarget + self.a = Assembler(target=self.t) + + def testMapOperand(self): + pass + + def testMovImm8(self): + self.a.assemble('mov r4, 100') + self.assertEqual(bytes.fromhex('6424'), self.a.binout) + + def testYield(self): + self.a.assemble('yield') + self.assertEqual(bytes.fromhex('10bf'), self.a.binout) + + if __name__ == '__main__': # cProfile.run('unittest.main()') unittest.main()