Mercurial > lcfOS
diff python/testasm.py @ 206:6c6bf8890d8a
Added push and pop encodings
author | Windel Bouwman |
---|---|
date | Fri, 28 Jun 2013 16:49:38 +0200 |
parents | ca1ea402f6a1 |
children | 8b2f20aae086 |
line wrap: on
line diff
--- a/python/testasm.py Sun Jun 23 18:23:18 2013 +0200 +++ b/python/testasm.py Fri Jun 28 16:49:38 2013 +0200 @@ -153,22 +153,36 @@ self.t = arm_cm3.armtarget self.a = Assembler(target=self.t) + def feed(self, line): + self.a.assemble(line) + + def check(self, hexstr): + self.assertEqual(bytes.fromhex(hexstr), self.a.binout) + def testMapOperand(self): pass def testMovImm8(self): - self.a.assemble('mov r4, 100') - self.assertEqual(bytes.fromhex('6424'), self.a.binout) + self.feed('mov r4, 100') + self.check('6424') def testYield(self): - self.a.assemble('yield') - self.assertEqual(bytes.fromhex('10bf'), self.a.binout) + self.feed('yield') + self.check('10bf') + + def testPush(self): + self.feed('push {r2,r3,lr}') + self.check('0cb5') + + def testPop(self): + self.feed('pop {r4-r6, pc}') + self.check('70bd') def testSequence1(self): - self.a.assemble('mov r5, 3') - self.a.assemble('add r4, r5, 0') - self.a.assemble('loop: add r6, r4, 7') - self.a.assemble('cmp r6, 5') + self.feed('mov r5, 3') + self.feed('add r4, r5, 0') + self.feed('loop: add r6, r4, 7') + self.feed('cmp r6, 5') #self.a.assemble('ble loop') #self.assertEqual(bytes.fromhex('0325 2c1c e61d 052e fcdd'), self.a.binout) self.assertEqual(bytes.fromhex('0325 2c1c e61d 052e'), self.a.binout) # without branch