summaryrefslogtreecommitdiff
path: root/pp2cc.py
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2011-11-29 11:59:10 +0000
committerPeter Wu <lekensteyn@gmail.com>2011-11-29 11:59:10 +0000
commit6890b1638700688df26e9d2cf809cfb8d976a15e (patch)
tree0d8204965ab9ee8981a9e27a3a95ef4ca795ccd8 /pp2cc.py
parenteabfc84fac0e42635cccabf5c8f883585da60de8 (diff)
downloadpp2cc-6890b1638700688df26e9d2cf809cfb8d976a15e.tar.gz
Fix detection of hexadecimal assembly numbers which do not start with $0
Diffstat (limited to 'pp2cc.py')
-rwxr-xr-xpp2cc.py8
1 files changed, 5 insertions, 3 deletions
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)