diff python/ppci/target/arm/instructions.py @ 365:98ff43cfdd36

Nasty bug in adr instruction
author Windel Bouwman
date Wed, 19 Mar 2014 22:32:04 +0100
parents c49459768aaa
children 19eacf4f7270
line wrap: on
line diff
--- a/python/ppci/target/arm/instructions.py	Wed Mar 19 20:24:03 2014 +0100
+++ b/python/ppci/target/arm/instructions.py	Wed Mar 19 22:32:04 2014 +0100
@@ -1,22 +1,11 @@
 
 from ..basetarget import Instruction, LabelAddress
-from ...bitfun import rotate_left
+from ...bitfun import encode_imm32
 
 from .token import ArmToken
 from .registers import R0, SP, ArmRegister
 
 
-def encode_imm32(v):
-    """ Bundle 32 bit value into 4 bits rotation and 8 bits value
-     """
-    for i in range(0, 16):
-        v2 = rotate_left(v, i*2)
-        if (v2 & 0xFFFFFF00) == 0:
-            rotation = i
-            val = v2 & 0xFF
-            x = (rotation << 8) | val
-            return x
-    raise Exception("Invalid value {}".format(v))
 
 # Instructions: