]> granicus.if.org Git - yasm/commitdiff
Fix #77 by performing symrec-symrec -> subst placeholder transformation
authorPeter Johnson <peter@tortall.net>
Sat, 30 Sep 2006 05:13:41 +0000 (05:13 -0000)
committerPeter Johnson <peter@tortall.net>
Sat, 30 Sep 2006 05:13:41 +0000 (05:13 -0000)
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
libyasm/tests/Makefile.inc
libyasm/tests/opt-oldalign.asm [new file with mode: 0644]
libyasm/tests/opt-oldalign.hex [new file with mode: 0644]

index 531ad604b5b55e92de835342f72b9a66c0226bb7..262863e81f26618826c7ce53b74407941a910cfd 100644 (file)
@@ -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;
 }
 
index e8b057eae248402b71e9642e57985beb12295821..f34f651c25cd89ba80dc96ff03e7d0bf542a0d82 100644 (file)
@@ -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 (file)
index 0000000..013a5c8
--- /dev/null
@@ -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 (file)
index 0000000..dfbb9da
--- /dev/null
@@ -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