]> granicus.if.org Git - yasm/commitdiff
Fix handling of times 0 <...>.
authorPeter Johnson <peter@tortall.net>
Sat, 3 Feb 2007 23:52:44 +0000 (23:52 -0000)
committerPeter Johnson <peter@tortall.net>
Sat, 3 Feb 2007 23:52:44 +0000 (23:52 -0000)
svn path=/trunk/yasm/; revision=1750

libyasm/bytecode.c
libyasm/tests/times0.asm [new file with mode: 0644]
libyasm/tests/times0.hex [new file with mode: 0644]

index 27ccfdc938115a150df679f1c54531148b698aa1..59c93b28b92cbafea22bf7d659749a48439da518 100644 (file)
@@ -167,7 +167,16 @@ yasm_bc_finalize(yasm_bytecode *bc, yasm_bytecode *prev_bc)
        else if (val.rel)
            yasm_error_set(YASM_ERROR_NOT_ABSOLUTE,
                           N_("multiple expression not absolute"));
-       bc->multiple = val.abs;
+       /* Finalize creates NULL output if value=0, but bc->multiple is NULL
+        * if value=1 (this difference is to make the common case small).
+        * However, this means we need to set bc->multiple explicitly to 0
+        * here if val.abs is NULL.
+        */
+       if (val.abs)
+           bc->multiple = val.abs;
+       else
+           bc->multiple = yasm_expr_create_ident(
+               yasm_expr_int(yasm_intnum_create_uint(0)), bc->line);
     }
 }
 
diff --git a/libyasm/tests/times0.asm b/libyasm/tests/times0.asm
new file mode 100644 (file)
index 0000000..ea642d7
--- /dev/null
@@ -0,0 +1 @@
+times 0 db 1
diff --git a/libyasm/tests/times0.hex b/libyasm/tests/times0.hex
new file mode 100644 (file)
index 0000000..e69de29