Mercurial > lcfOS
diff python/ppci/target/arm/__init__.py @ 362:c05ab629976a
Added CPUID for arm
author | Windel Bouwman |
---|---|
date | Sat, 15 Mar 2014 10:56:34 +0100 |
parents | b4ac28efcdf4 |
children | c49459768aaa |
line wrap: on
line diff
--- a/python/ppci/target/arm/__init__.py Fri Mar 14 16:18:54 2014 +0100 +++ b/python/ppci/target/arm/__init__.py Sat Mar 15 10:56:34 2014 +0100 @@ -8,6 +8,7 @@ from .instructions import Lsr1, Lsl1, And1, Sub1 from .instructions import B, Bl, Ble, Bgt, Beq, Blt, Cmp, Cmp2 from .instructions import Push, Pop, Str, Ldr, Ldr3, Str1, Ldr1, Adr +from .instructions import Mcr, Mrc from .selector import ArmInstructionSelector from .frame import ArmFrame @@ -75,6 +76,8 @@ self.add_keyword('mov') self.add_instruction(['mov', 'reg', ',', 'imm32'], lambda rhs: Mov(rhs[1], rhs[3])) + self.add_instruction(['mov', 'reg', ',', 'reg'], + lambda rhs: Mov(rhs[1], rhs[3])) self.add_keyword('cmp') self.add_instruction(['cmp', 'reg', ',', 'imm32'], @@ -169,3 +172,25 @@ self.add_rule('reg_or_range', ['reg', '-', 'reg'], lambda rhs: register_range(rhs[0], rhs[2])) + + # Add MCR and MRC (co-processor) + for i in range(16): + creg = 'c{}'.format(i) + self.add_keyword(creg) + self.add_rule('coreg', [creg], i) + + for i in range(8, 16): + px = 'p{}'.format(i) + self.add_keyword(px) + # Ran into trouble when using i inside lambda function: + # When using inside lambda (as a closure), i is bound to the latest + # value (15) + self.add_rule('coproc', [px], i) + + self.add_keyword('mcr') + self.add_instruction(['mcr', 'coproc', ',', 'imm3', ',', 'reg', ',', 'coreg', ',', 'coreg', ',', 'imm3'], + lambda rhs: Mcr(rhs[1], rhs[3], rhs[5], rhs[7], rhs[9], rhs[11])) + + self.add_keyword('mrc') + self.add_instruction(['mrc', 'coproc', ',', 'imm3', ',', 'reg', ',', 'coreg', ',', 'coreg', ',', 'imm3'], + lambda rhs: Mrc(rhs[1], rhs[3], rhs[5], rhs[7], rhs[9], rhs[11]))