]> granicus.if.org Git - yasm/commitdiff
Fix expression handling of unary NOT (~ in nasm syntax) operator.
authorPeter Johnson <peter@tortall.net>
Sun, 26 Oct 2003 02:34:29 +0000 (02:34 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 26 Oct 2003 02:34:29 +0000 (02:34 -0000)
Reported by: Edouard Gomez <ed.gomez@free.fr>

svn path=/trunk/yasm/; revision=1079

libyasm/expr.c
libyasm/tests/Makefile.inc
libyasm/tests/unary.asm [new file with mode: 0644]
libyasm/tests/unary.errwarn [new file with mode: 0644]
libyasm/tests/unary.hex [new file with mode: 0644]

index b0d0bb8a3c0cf9b64aa43ff811aa92a60b15ced5..f25a38db0f61bbdd1b043dce19bbd27f12841025 100644 (file)
@@ -478,6 +478,11 @@ expr_simplify_identity(yasm_expr *e, int numterms, int int_term)
        numterms = 1;
     }
 
+    /* Compute NOT and NEG on single intnum. */
+    if (numterms == 1 && int_term == 0 &&
+       (e->op == YASM_EXPR_NOT || e->op == YASM_EXPR_NEG))
+       yasm_intnum_calc(e->terms[0].data.intn, e->op, NULL, e->line);
+
     /* Change expression to IDENT if possible. */
     if (numterms == 1)
        e->op = YASM_EXPR_IDENT;
index 61c7be0f2a9e00a578bead06b95ae64e25139905..c38aca97128cc48dd20a5d45a5aa454baadad4df 100644 (file)
@@ -7,6 +7,9 @@ TESTS += libyasm/tests/libyasm_test.sh
 EXTRA_DIST += libyasm/tests/libyasm_test.sh
 EXTRA_DIST += libyasm/tests/duplabel-err.asm
 EXTRA_DIST += libyasm/tests/duplabel-err.errwarn
+EXTRA_DIST += libyasm/tests/unary.asm
+EXTRA_DIST += libyasm/tests/unary.errwarn
+EXTRA_DIST += libyasm/tests/unary.hex
 
 noinst_PROGRAMS += bitvect_test
 noinst_PROGRAMS += floatnum_test
diff --git a/libyasm/tests/unary.asm b/libyasm/tests/unary.asm
new file mode 100644 (file)
index 0000000..e0bcc17
--- /dev/null
@@ -0,0 +1,5 @@
+[bits 32]
+mov eax, ~0
+mov eax, ~5
+mov ebx, -0
+mov ebx, -5
diff --git a/libyasm/tests/unary.errwarn b/libyasm/tests/unary.errwarn
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/libyasm/tests/unary.hex b/libyasm/tests/unary.hex
new file mode 100644 (file)
index 0000000..ed29c52
--- /dev/null
@@ -0,0 +1,20 @@
+b8 
+ff 
+ff 
+ff 
+ff 
+b8 
+fa 
+ff 
+ff 
+ff 
+bb 
+00 
+00 
+00 
+00 
+bb 
+fb 
+ff 
+ff 
+ff