diff python/ppci/target/thumb/instructions.py @ 346:3bb7dcfe5529

expanded arm target
author Windel Bouwman
date Fri, 07 Mar 2014 17:05:32 +0100
parents 86b02c98a717
children
line wrap: on
line diff
--- a/python/ppci/target/thumb/instructions.py	Sun Mar 02 17:12:08 2014 +0100
+++ b/python/ppci/target/thumb/instructions.py	Fri Mar 07 17:05:32 2014 +0100
@@ -1,5 +1,4 @@
 from ..basetarget import Register, Instruction, Target, Label
-from ..basetarget import Imm32, Imm8, Imm7, Imm3
 from ..token import u16, u32
 from .armtoken import ThumbToken
 from ..arm.registers import R0, ArmRegister, SP
@@ -13,10 +12,7 @@
 
 class Dcd(ThumbInstruction):
     def __init__(self, expr):
-        if isinstance(expr, Imm32):
-            self.expr = expr.imm
-            self.label = None
-        elif isinstance(expr, int):
+        if isinstance(expr, int):
             self.expr = expr
             self.label = None
         else:
@@ -71,17 +67,10 @@
 class Str2(LS_imm5_base):
     opcode = 0xC
 
-    @classmethod
-    def fromim(cls, im):
-        return cls(im.src[1], im.src[0], im.others[0])
-
 
 class Ldr2(LS_imm5_base):
     opcode = 0xD
 
-    @classmethod
-    def fromim(cls, im):
-        return cls(im.dst[0], im.src[0], im.others[0])
 
 class ls_sp_base_imm8(ThumbInstruction):
     def __init__(self, rt, offset):
@@ -100,10 +89,6 @@
         mnemonic = self.__class__.__name__
         return '{} {}, [sp,#{}]'.format(mnemonic, self.rt, self.offset)
 
-def align(x, m):
-    while ((x % m) != 0):
-        x = x + 1
-    return x
 
 def Ldr(*args):
     if len(args) == 2 and isinstance(args[0], ArmRegister) \
@@ -115,15 +100,10 @@
 
 class Ldr3(ThumbInstruction):
     """ ldr Rt, LABEL, load value from pc relative position """
-    mnemonic = 'ldr'
     def __init__(self, rt, label):
         self.rt = rt
         self.label = label
 
-    @classmethod
-    def fromim(cls, im):
-        return cls(im.dst[0], im.others[0])
-
     def relocations(self):
         return [(self.label, 'lit_add_8')]
 
@@ -157,10 +137,6 @@
         self.rd = rd
         self.token = ThumbToken()
 
-    @classmethod
-    def fromim(cls, im):
-        return cls(im.dst[0], im.others[0])
-
     def encode(self):
         rd = self.rd.num
         self.token[8:11] = rd
@@ -172,11 +148,9 @@
         return 'MOV {}, {}'.format(self.rd, self.imm)
 
 
-
 # Arithmatics:
 
 
-
 class regregimm3_base(ThumbInstruction):
     def __init__(self, rd, rn, imm3):
         self.rd = rd
@@ -185,10 +159,6 @@
         self.imm3 = imm3
         self.token = ThumbToken()
 
-    @classmethod
-    def fromim(cls, im):
-        return cls(im.dst[0], im.src[0], im.others[0])
-
     def encode(self):
         rd = self.rd.num
         self.token[0:3] = rd
@@ -244,10 +214,6 @@
         self.rn = rn
         self.rm = rm
 
-    @classmethod
-    def fromim(cls, im):
-        return cls(im.dst[0], im.src[0], im.src[1])
-
     def encode(self):
         at = ThumbToken()
         at.rd = self.rd.num
@@ -279,10 +245,6 @@
         self.rd = rd
         self.rm = rm
 
-    @classmethod
-    def fromim(cls, im):
-        return cls(im.dst[0], im.src[0])
-
     def encode(self):
         at = ThumbToken()
         at.rd = self.rd.num & 0x7
@@ -305,11 +267,6 @@
         self.rn = rn
         self.rdm = rdm
 
-    @classmethod
-    def fromim(cls, im):
-        assert im.src[1] is im.dst[0]
-        return cls(im.src[0], im.dst[0])
-
     def encode(self):
         at = ThumbToken()
         rn = self.rn.num
@@ -330,10 +287,6 @@
         self.rdn = rdn
         self.rm = rm
 
-    @classmethod
-    def fromim(cls, im):
-        return cls(im.src[0], im.src[1])
-
     def encode(self):
         at = ThumbToken()
         at.rd = self.rdn.num