Mercurial > lcfOS
diff python/ppci/target/arm/instructions.py @ 342:86b02c98a717 devel
Moved target directory
author | Windel Bouwman |
---|---|
date | Sat, 01 Mar 2014 15:40:31 +0100 |
parents | |
children | b4882ff0ed06 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/ppci/target/arm/instructions.py Sat Mar 01 15:40:31 2014 +0100 @@ -0,0 +1,37 @@ + + +from ..basetarget import Instruction + +from .token import ArmToken +from .registers import R0, SP + + +# Instructions: + +class ArmInstruction(Instruction): + def __init__(self): + self.token = ArmToken() + + +class Mov(ArmInstruction): + """ Mov Rd, imm16 """ + def __init__(self, reg, imm): + super().__init__() + self.reg = reg + self.imm = imm + + def encode(self): + self.token[0:12] = self.imm + self.token[12:16] = self.reg.num + self.token[16:20] = 0 + self.token[20] = 0 + self.token[21:28] = 0b0011101 + self.token.cond = 0xE # Always! + return self.token.encode() + + def relocations(self): + return [] + + def __repr__(self): + return 'DCD 0x{0:X}'.format(self.expr) +