From: Peter Johnson Date: Sun, 26 Oct 2003 02:34:29 +0000 (-0000) Subject: Fix expression handling of unary NOT (~ in nasm syntax) operator. X-Git-Tag: v0.4.0~86 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=742d8359be817022aaf6b18a8b51819eec489aa1;p=yasm Fix expression handling of unary NOT (~ in nasm syntax) operator. Reported by: Edouard Gomez svn path=/trunk/yasm/; revision=1079 --- diff --git a/libyasm/expr.c b/libyasm/expr.c index b0d0bb8a..f25a38db 100644 --- a/libyasm/expr.c +++ b/libyasm/expr.c @@ -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; diff --git a/libyasm/tests/Makefile.inc b/libyasm/tests/Makefile.inc index 61c7be0f..c38aca97 100644 --- a/libyasm/tests/Makefile.inc +++ b/libyasm/tests/Makefile.inc @@ -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 index 00000000..e0bcc177 --- /dev/null +++ b/libyasm/tests/unary.asm @@ -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 index 00000000..e69de29b diff --git a/libyasm/tests/unary.hex b/libyasm/tests/unary.hex new file mode 100644 index 00000000..ed29c522 --- /dev/null +++ b/libyasm/tests/unary.hex @@ -0,0 +1,20 @@ +b8 +ff +ff +ff +ff +b8 +fa +ff +ff +ff +bb +00 +00 +00 +00 +bb +fb +ff +ff +ff