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