summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpp2cc.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/pp2cc.py b/pp2cc.py
index 5dce20c..b130356 100755
--- a/pp2cc.py
+++ b/pp2cc.py
@@ -622,9 +622,9 @@ class Parse(object):
elif op == "-":
lines.append(self.asm.binary_op("MULS", reg, "-1"))
elif op == "~":
- # XXX unsigned vs signed integers. Assume signed for now
- mask = "1" * (self.WORDSIZE - 1)
- lines.append(self.asm.binary_op("XOR", reg, "%0" + mask))
+ # Conforming K&R A7.4.6, signed types are treated as unsigned when
+ # applying ~
+ lines.append(self.asm.binary_op("XOR", reg, "%1"))
elif op == "!":
lbl_false = self.uniqLbl("not_false")
lbl_true = self.uniqLbl("not_true")