comparison python/ppci/target/arm/instructions.py @ 353:b8ad45b3a573

Started with strings
author Windel Bouwman
date Sun, 09 Mar 2014 18:49:10 +0100
parents 899ae3aea803
children 5477e499b039
comparison
equal deleted inserted replaced
352:899ae3aea803 353:b8ad45b3a573
23 class ArmInstruction(Instruction): 23 class ArmInstruction(Instruction):
24 def __init__(self): 24 def __init__(self):
25 self.token = ArmToken() 25 self.token = ArmToken()
26 26
27 27
28 class Dcd(ArmInstruction): 28 class ConstantData(ArmInstruction):
29 def __init__(self, v): 29 def __init__(self, v):
30 super().__init__() 30 super().__init__()
31 assert isinstance(v, int)
31 self.v = v 32 self.v = v
32 33
34 def __repr__(self):
35 return 'DCD {}'.format(hex(self.v))
36
37
38 class Dcd(ConstantData):
33 def encode(self): 39 def encode(self):
34 self.token[0:32] = self.v 40 self.token[0:32] = self.v
35 return self.token.encode() 41 return self.token.encode()
36 42
37 def __repr__(self): 43 def __repr__(self):
38 return 'DCD {}'.format(hex(self.v)) 44 return 'DCD {}'.format(hex(self.v))
45
46
47 class Db(ConstantData):
48 def encode(self):
49 assert self.v < 256
50 return bytes([self.v])
51
52 def __repr__(self):
53 return 'DB {}'.format(hex(self.v))
39 54
40 55
41 def Mov(*args): 56 def Mov(*args):
42 if len(args) == 2: 57 if len(args) == 2:
43 if isinstance(args[1], int): 58 if isinstance(args[1], int):