Mercurial > lcfOS
diff python/ppci/target/arm/__init__.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 diff
--- a/python/ppci/target/arm/__init__.py Sat Mar 01 16:32:27 2014 +0100 +++ b/python/ppci/target/arm/__init__.py Sun Mar 02 17:12:08 2014 +0100 @@ -1,16 +1,16 @@ from ..basetarget import Target -from ..arm.registers import R0, R1, R2, R3, R4, R5, R6, R7, SP, LR, PC +from ..arm.registers import R0, R1, R2, R3, R4, R5, R6, R7 +from ..arm.registers import R8, R9, R10, R11, R12, SP, LR, PC from ..arm.registers import register_range -from .instructions import Mov +from .instructions import Mov, Add, Sub, Orr1, B, Bl, Ble, Bgt, Beq -class ArmArmTarget(Target): +class ArmTarget(Target): def __init__(self): super().__init__('arm_arm') # Assembly grammar: - self.add_keyword('mov') self.add_keyword('r0') self.add_keyword('r1') self.add_keyword('r2') @@ -19,6 +19,11 @@ self.add_keyword('r5') self.add_keyword('r6') self.add_keyword('r7') + self.add_keyword('r8') + self.add_keyword('r9') + self.add_keyword('r10') + self.add_keyword('r11') + self.add_keyword('r12') self.add_rule('reg', ['r0'], lambda rhs: R0) self.add_rule('reg', ['r1'], lambda rhs: R1) @@ -28,15 +33,45 @@ self.add_rule('reg', ['r5'], lambda rhs: R5) self.add_rule('reg', ['r6'], lambda rhs: R6) self.add_rule('reg', ['r7'], lambda rhs: R7) + self.add_rule('reg', ['r8'], lambda rhs: R8) + self.add_rule('reg', ['r9'], lambda rhs: R9) + self.add_rule('reg', ['r10'], lambda rhs: R10) + self.add_rule('reg', ['r11'], lambda rhs: R11) + self.add_rule('reg', ['r12'], lambda rhs: R12) + self.add_keyword('mov') self.add_instruction(['mov', 'reg', ',', 'imm8'], lambda rhs: Mov(rhs[1], rhs[3])) - self.add_rule('imm32', ['val32'], lambda x: x[0].val) - self.add_rule('imm32', ['imm8'], lambda x: x[0]) - self.add_rule('imm8', ['val8'], lambda x: x[0].val) - self.add_rule('imm8', ['imm5'], lambda x: x[0]) - self.add_rule('imm5', ['val5'], lambda x: x[0].val) - self.add_rule('imm5', ['imm3'], lambda x: x[0]) - self.add_rule('imm3', ['val3'], lambda x: x[0].val) + self.add_keyword('add') + self.add_instruction(['add', 'reg', ',', 'reg', ',', 'imm32'], + lambda rhs: Add(rhs[1], rhs[3], rhs[5])) + + self.add_instruction(['add', 'reg', ',', 'reg', ',', 'reg'], + lambda rhs: Add(rhs[1], rhs[3], rhs[5])) + + self.add_keyword('sub') + self.add_instruction(['sub', 'reg', ',', 'reg', ',', 'imm32'], + lambda rhs: Sub(rhs[1], rhs[3], rhs[5])) + + self.add_instruction(['sub', 'reg', ',', 'reg', ',', 'reg'], + lambda rhs: Sub(rhs[1], rhs[3], rhs[5])) + + self.add_keyword('orr') + self.add_instruction(['orr', 'reg', ',', 'reg', ',', 'reg'], + lambda rhs: Orr1(rhs[1], rhs[3], rhs[5])) + + + # Jumping: + self.add_keyword('b') + self.add_instruction(['b', 'ID'], lambda rhs: B(rhs[1].val)) + self.add_keyword('ble') + self.add_instruction(['ble', 'ID'], lambda rhs: Ble(rhs[1].val)) + self.add_keyword('bgt') + self.add_instruction(['bgt', 'ID'], lambda rhs: Bgt(rhs[1].val)) + self.add_keyword('beq') + self.add_instruction(['beq', 'ID'], lambda rhs: Beq(rhs[1].val)) + + self.add_keyword('bl') + self.add_instruction(['bl', 'ID'], lambda rhs: Bl(rhs[1].val))