annotate 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
rev   line source
342
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
1
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
2
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
3 from ..basetarget import Instruction
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
4
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
5 from .token import ArmToken
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
6 from .registers import R0, SP
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
7
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
8
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
9 # Instructions:
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
10
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
11 class ArmInstruction(Instruction):
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
12 def __init__(self):
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
13 self.token = ArmToken()
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
14
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
15
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
16 class Mov(ArmInstruction):
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
17 """ Mov Rd, imm16 """
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
18 def __init__(self, reg, imm):
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
19 super().__init__()
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
20 self.reg = reg
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
21 self.imm = imm
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
22
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
23 def encode(self):
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
24 self.token[0:12] = self.imm
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
25 self.token[12:16] = self.reg.num
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
26 self.token[16:20] = 0
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
27 self.token[20] = 0
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
28 self.token[21:28] = 0b0011101
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
29 self.token.cond = 0xE # Always!
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
30 return self.token.encode()
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
31
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
32 def relocations(self):
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
33 return []
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
34
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
35 def __repr__(self):
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
36 return 'DCD 0x{0:X}'.format(self.expr)
86b02c98a717 Moved target directory
Windel Bouwman
parents:
diff changeset
37