about summary refs log tree commit diff stats
path: root/miasm2/arch
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--miasm2/arch/arm/arch.py12
-rw-r--r--miasm2/arch/msp430/arch.py3
-rw-r--r--miasm2/arch/x86/arch.py8
3 files changed, 13 insertions, 10 deletions
diff --git a/miasm2/arch/arm/arch.py b/miasm2/arch/arm/arch.py
index 87af007a..4ecfbd97 100644
--- a/miasm2/arch/arm/arch.py
+++ b/miasm2/arch/arm/arch.py
@@ -485,6 +485,10 @@ class instruction_armt(instruction_arm):
             raise ValueError('strange offset! %r' % off)
         self.args[0] = ExprInt32(off)
 
+    def get_asm_offset(self, x):
+        # ADR XXX, PC, imm => PC is 4 aligned + imm
+        new_offset = ((self.offset+self.l)/4)*4
+        return ExprInt_from(x, new_offset)
 
 
 class mn_arm(cls_mn):
@@ -501,6 +505,7 @@ class mn_arm(cls_mn):
     sp = {'l':SP, 'b':SP}
     instruction = instruction_arm
     max_instruction_len = 4
+    alignment = 4
 
     @classmethod
     def getpc(cls, attrib = None):
@@ -599,7 +604,8 @@ class mn_armt(cls_mn):
     pc = PC
     sp = SP
     instruction = instruction_armt
-    max_instruction_len = 8
+    max_instruction_len = 4
+    alignment = 4
 
     @classmethod
     def getpc(cls, attrib = None):
@@ -784,7 +790,9 @@ class arm_offs(arm_imm):
         return v << 2
 
     def encodeval(self, v):
-        return v >> 2
+        if v%4 == 0:
+            return v >> 2
+        return False
 
     def decode(self, v):
         v = v & self.lmask
diff --git a/miasm2/arch/msp430/arch.py b/miasm2/arch/msp430/arch.py
index 6c622ce7..07a11ae8 100644
--- a/miasm2/arch/msp430/arch.py
+++ b/miasm2/arch/msp430/arch.py
@@ -188,8 +188,7 @@ class instruction_msp430(instruction):
             # raise ValueError('dst must be int or label')
             log.warning('dynamic dst %r', e)
             return
-        # return ExprInt32(e.arg - (self.offset + self.l))
-        self.args[0] = ExprInt_fromsize(16, e.arg - (self.offset + self.l))
+        self.args[0] = ExprInt_fromsize(16, (e.arg - (self.offset + self.l))/2)
 
     def get_info(self, c):
         pass
diff --git a/miasm2/arch/x86/arch.py b/miasm2/arch/x86/arch.py
index ef6a6fb9..3b714f79 100644
--- a/miasm2/arch/x86/arch.py
+++ b/miasm2/arch/x86/arch.py
@@ -488,12 +488,8 @@ class instruction_x86(instruction):
             return
         e = self.args[0]
         if isinstance(e, ExprId):
-            if isinstance(e.name, asm_label):
-                pass
-            elif not e.name in all_regs_ids_byname:
-                l = symbol_pool.getby_name_create(e.name)
-                s = ExprId(l, e.size)
-                self.args[0] = s
+            if not isinstance(e.name, asm_label) and e not in all_regs_ids:
+                raise ValueError("ExprId must be a label or a register")
         elif isinstance(e, ExprInt):
             ad = e.arg + int(self.offset) + self.l
             l = symbol_pool.getby_offset_create(ad)