summaryrefslogtreecommitdiff
path: root/pp2cc.py
diff options
context:
space:
mode:
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)