From 95e57a41e47c793835cbf66e37e434bcf61b6f74 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 3 Feb 2007 23:52:44 +0000 Subject: [PATCH] Fix handling of times 0 <...>. svn path=/trunk/yasm/; revision=1750 --- libyasm/bytecode.c | 11 ++++++++++- libyasm/tests/times0.asm | 1 + libyasm/tests/times0.hex | 0 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 libyasm/tests/times0.asm create mode 100644 libyasm/tests/times0.hex diff --git a/libyasm/bytecode.c b/libyasm/bytecode.c index 27ccfdc9..59c93b28 100644 --- a/libyasm/bytecode.c +++ b/libyasm/bytecode.c @@ -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 index 00000000..ea642d79 --- /dev/null +++ b/libyasm/tests/times0.asm @@ -0,0 +1 @@ +times 0 db 1 diff --git a/libyasm/tests/times0.hex b/libyasm/tests/times0.hex new file mode 100644 index 00000000..e69de29b -- 2.40.0