Mercurial > lcfOS
diff python/cortexm3.py @ 236:8786811a5a59
Fix pcrel
author | Windel Bouwman |
---|---|
date | Mon, 15 Jul 2013 20:15:31 +0200 |
parents | ff40407c0240 |
children | 81752b0f85a5 |
line wrap: on
line diff
--- a/python/cortexm3.py Mon Jul 15 17:20:37 2013 +0200 +++ b/python/cortexm3.py Mon Jul 15 20:15:31 2013 +0200 @@ -263,6 +263,11 @@ def __repr__(self): return '{} {}, [sp,#{}]'.format(self.mnemonic, self.rt, self.offset) +def align(x, m): + while ((x % m) != 0): + x = x + 1 + return x + @armtarget.instruction class ldr_pcrel(ArmInstruction): """ ldr Rt, [PC, imm8], store value into memory """ @@ -276,8 +281,8 @@ def resolve(self, f): la = f(self.label.name) - print(la) - self.offset = (la - self.address) + 4 + sa = align(self.address + 2, 4) + self.offset = (la - sa) if self.offset < 0: self.offset = 0 @@ -288,7 +293,6 @@ assert imm8 < 256 assert imm8 >= 0 h = (0x9 << 11) | (rt << 8) | imm8 - print(hex(h)) return u16(h) def __repr__(self):