comparison 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
comparison
equal deleted inserted replaced
364:c49459768aaa 365:98ff43cfdd36
1 1
2 from ..basetarget import Instruction, LabelAddress 2 from ..basetarget import Instruction, LabelAddress
3 from ...bitfun import rotate_left 3 from ...bitfun import encode_imm32
4 4
5 from .token import ArmToken 5 from .token import ArmToken
6 from .registers import R0, SP, ArmRegister 6 from .registers import R0, SP, ArmRegister
7 7
8 8
9 def encode_imm32(v):
10 """ Bundle 32 bit value into 4 bits rotation and 8 bits value
11 """
12 for i in range(0, 16):
13 v2 = rotate_left(v, i*2)
14 if (v2 & 0xFFFFFF00) == 0:
15 rotation = i
16 val = v2 & 0xFF
17 x = (rotation << 8) | val
18 return x
19 raise Exception("Invalid value {}".format(v))
20 9
21 # Instructions: 10 # Instructions:
22 11
23 class ArmInstruction(Instruction): 12 class ArmInstruction(Instruction):
24 def __init__(self): 13 def __init__(self):