From 6890b1638700688df26e9d2cf809cfb8d976a15e Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 29 Nov 2011 11:59:10 +0000 Subject: Fix detection of hexadecimal assembly numbers which do not start with $0 --- pp2cc.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'pp2cc.py') diff --git a/pp2cc.py b/pp2cc.py index a1d1bbd..0e3fe28 100755 --- a/pp2cc.py +++ b/pp2cc.py @@ -724,10 +724,12 @@ class Parse(object): if str.startswith("$0"): return int(str[2:], 16) else: - # anything with a leading 8 or higher is padded... assembler - # bug? + # if the leftmost bit of a 4-bit group is set, the preceding + # bits should be 1 as well. E.g. $7 end with 0111 and is + # therefore interpreted as 7 where $8 ends with 1111 which is + # interpreted as -1 (all bits are set) val = str[1:] - if int(val[1]) >= 8: + if int(val[1], 16) & 0b1000: hexsize = len(hex(pow(2, self.WORDSIZE) - 1)[2:]) val = val.rjust(hexsize, "F") return int(val, 16) -- cgit v1.2.1