diff --git a/src/asm/format.c b/src/asm/format.c index 1a38aa56..456cfc25 100644 --- a/src/asm/format.c +++ b/src/asm/format.c @@ -182,10 +182,9 @@ void fmt_PrintNumber(char *buf, size_t bufLen, struct FormatSpec const *fmt, uin if (fmt->type == 'd' || fmt->type == 'f') { int32_t v = value; - if (v < 0) { + if (v < 0 && v != INT32_MIN) { sign = '-'; - if (v != INT32_MIN) - value = -v; + value = -v; } } diff --git a/test/asm/minimum-int.asm b/test/asm/minimum-int.asm new file mode 100644 index 00000000..5c3cfc66 --- /dev/null +++ b/test/asm/minimum-int.asm @@ -0,0 +1,8 @@ +m = $8000_0000 +assert m == 1 << 31 +assert m == -(1 << 31) +assert m == (-2)**31 + + println "{m}" + println "({12d:m})" + println "({-12d:m})" diff --git a/test/asm/minimum-int.err b/test/asm/minimum-int.err new file mode 100644 index 00000000..e69de29b diff --git a/test/asm/minimum-int.out b/test/asm/minimum-int.out new file mode 100644 index 00000000..a36897da --- /dev/null +++ b/test/asm/minimum-int.out @@ -0,0 +1,3 @@ +$80000000 +( -2147483648) +(-2147483648 )