From 9b2aaa97bdf26b6ef57f2c556e78df9bb812554d Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 30 Sep 2006 05:13:41 +0000 Subject: [PATCH] Fix #77 by performing symrec-symrec -> subst placeholder transformation recursively in yasm_expr__bc_dist_subst(); before this we would only do one level, which fails on simple structures like the old NASM align approach of "($$-$) & value" (as the $$-$ is one level down in the expression). svn path=/trunk/yasm/; revision=1635 --- libyasm/expr.c | 9 ++++++++- libyasm/tests/Makefile.inc | 2 ++ libyasm/tests/opt-oldalign.asm | 3 +++ libyasm/tests/opt-oldalign.hex | 35 ++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 libyasm/tests/opt-oldalign.asm create mode 100644 libyasm/tests/opt-oldalign.hex diff --git a/libyasm/expr.c b/libyasm/expr.c index 531ad604..262863e8 100644 --- a/libyasm/expr.c +++ b/libyasm/expr.c @@ -339,6 +339,12 @@ expr_bc_dist_subst_cb(yasm_expr__item *ei, yasm_bytecode *precbc, return 1; } +static yasm_expr * +expr_xform_bc_dist_subst(yasm_expr *e, void *d) +{ + return expr_xform_bc_dist_base(e, d, expr_bc_dist_subst_cb); +} + int yasm_expr__bc_dist_subst(yasm_expr **ep, void *cbd, void (*callback) (unsigned int subst, @@ -350,7 +356,8 @@ yasm_expr__bc_dist_subst(yasm_expr **ep, void *cbd, my_cbd.callback = callback; my_cbd.cbd = cbd; my_cbd.subst = 0; - *ep = expr_xform_bc_dist_base(*ep, &my_cbd, expr_bc_dist_subst_cb); + *ep = yasm_expr__level_tree(*ep, 1, 1, 1, 0, &expr_xform_bc_dist_subst, + &my_cbd, NULL); return my_cbd.subst; } diff --git a/libyasm/tests/Makefile.inc b/libyasm/tests/Makefile.inc index e8b057ea..f34f651c 100644 --- a/libyasm/tests/Makefile.inc +++ b/libyasm/tests/Makefile.inc @@ -45,6 +45,8 @@ EXTRA_DIST += libyasm/tests/opt-immexpand.asm EXTRA_DIST += libyasm/tests/opt-immexpand.hex EXTRA_DIST += libyasm/tests/opt-immnoexpand.asm EXTRA_DIST += libyasm/tests/opt-immnoexpand.hex +EXTRA_DIST += libyasm/tests/opt-oldalign.asm +EXTRA_DIST += libyasm/tests/opt-oldalign.hex EXTRA_DIST += libyasm/tests/opt-struc.asm EXTRA_DIST += libyasm/tests/opt-struc.hex EXTRA_DIST += libyasm/tests/timesover-err.asm diff --git a/libyasm/tests/opt-oldalign.asm b/libyasm/tests/opt-oldalign.asm new file mode 100644 index 00000000..013a5c83 --- /dev/null +++ b/libyasm/tests/opt-oldalign.asm @@ -0,0 +1,3 @@ +mov ax, 5 +times ($$-$) & 1Fh nop ; Long word alignment +mov bx, 5 diff --git a/libyasm/tests/opt-oldalign.hex b/libyasm/tests/opt-oldalign.hex new file mode 100644 index 00000000..dfbb9da9 --- /dev/null +++ b/libyasm/tests/opt-oldalign.hex @@ -0,0 +1,35 @@ +b8 +05 +00 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +90 +bb +05 +00