Mercurial > lcfOS
diff test/testmsp430asm.py @ 290:7b38782ed496
File moves
author | Windel Bouwman |
---|---|
date | Sun, 24 Nov 2013 11:24:15 +0100 |
parents | |
children | 534b94b40aa8 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/testmsp430asm.py Sun Nov 24 11:24:15 2013 +0100 @@ -0,0 +1,49 @@ +#!/usr/bin/python + +import unittest +from asmnodes import AInstruction, ABinop, AUnop, ASymbol, ALabel, ANumber +from asm import tokenize, Assembler +import msp430 +import outstream +from target import Label +from testasm import AsmTestCaseBase + + +class AssemblerMSP430TestCase(AsmTestCaseBase): + def setUp(self): + self.t = msp430.msp430target + self.o = outstream.BinOutputStream() + self.o.selectSection('.text') + self.a = Assembler(target=self.t, stream=self.o) + + def testMapMovInstruction(self): + i = AInstruction('mov', [ASymbol('r14'), ASymbol('r15')]) + ri = self.t.mapInstruction(i) + + def testMapRetiInstruction(self): + i = AInstruction('reti', []) + ri = self.t.mapInstruction(i) + + def testMov(self): + self.feed("mov r14, r15") + self.check('0F4E') + + def testMov1337(self): + self.feed("mov 0x1337, r12") + self.check('3C403713') + + def testAdd(self): + self.feed("add r15, r13") + self.check('0D5F') + + def testReti(self): + self.feed("reti") + self.check('0013') + + def testMSPinstructionCount(self): + """ Check that there are 27 instructions """ + self.assertEqual(27, len(self.t.instructions)) + + +if __name__ == '__main__': + unittest.main()