From: Peter Johnson Date: Sun, 4 Feb 2007 00:34:28 +0000 (-0000) Subject: Allow multiples to become temporarily negative during optimization. X-Git-Tag: v0.6.0~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d260877b316379f0372f67de5b2275c706c18615;p=yasm Allow multiples to become temporarily negative during optimization. Negative multiples are still checked for during output. svn path=/trunk/yasm/; revision=1752 --- diff --git a/libyasm/bc-int.h b/libyasm/bc-int.h index 66f22a21..5bcd22e3 100644 --- a/libyasm/bc-int.h +++ b/libyasm/bc-int.h @@ -58,7 +58,7 @@ struct yasm_bytecode { unsigned long len; /* total length of entire bytecode (not including multiple copies) */ - unsigned long mult_int; /* number of copies: integer version */ + long mult_int; /* number of copies: integer version */ /* where it came from */ unsigned long line; diff --git a/libyasm/bytecode.c b/libyasm/bytecode.c index 59c93b28..7fe31be8 100644 --- a/libyasm/bytecode.c +++ b/libyasm/bytecode.c @@ -230,7 +230,7 @@ yasm_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, yasm_error_set(YASM_ERROR_VALUE, N_("multiple is negative")); retval = -1; } else - bc->mult_int = yasm_intnum_get_uint(num); + bc->mult_int = yasm_intnum_get_int(num); } else { if (yasm_expr__contains(bc->multiple, YASM_EXPR_FLOAT)) { yasm_error_set(YASM_ERROR_VALUE, @@ -257,11 +257,7 @@ yasm_bc_expand(yasm_bytecode *bc, int span, long old_val, long new_val, /*@out@*/ long *neg_thres, /*@out@*/ long *pos_thres) { if (span == 0) { - if (new_val < 0) { - yasm_error_set(YASM_ERROR_VALUE, N_("multiple is negative")); - return -1; - } - bc->mult_int = (unsigned long)new_val; + bc->mult_int = new_val; return 1; } if (!bc->callback) { @@ -282,7 +278,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize, { /*@only@*/ /*@null@*/ unsigned char *mybuf = NULL; unsigned char *origbuf, *destbuf; - unsigned long i; + long i; int error = 0; if (yasm_bc_get_multiple(bc, &bc->mult_int, 1) || bc->mult_int == 0) { @@ -322,8 +318,7 @@ yasm_bc_tobytes(yasm_bytecode *bc, unsigned char *buf, unsigned long *bufsize, } int -yasm_bc_get_multiple(yasm_bytecode *bc, unsigned long *multiple, - int calc_bc_dist) +yasm_bc_get_multiple(yasm_bytecode *bc, long *multiple, int calc_bc_dist) { /*@dependent@*/ /*@null@*/ const yasm_intnum *num; @@ -339,7 +334,7 @@ yasm_bc_get_multiple(yasm_bytecode *bc, unsigned long *multiple, yasm_error_set(YASM_ERROR_VALUE, N_("multiple is negative")); return 1; } - *multiple = yasm_intnum_get_uint(num); + *multiple = yasm_intnum_get_int(num); } return 0; } diff --git a/libyasm/bytecode.h b/libyasm/bytecode.h index 0c406ef1..e26b9017 100644 --- a/libyasm/bytecode.h +++ b/libyasm/bytecode.h @@ -383,7 +383,7 @@ int yasm_bc_expand(yasm_bytecode *bc, int span, long old_val, long new_val, * calculated, 0 if error should be returned in this case * \return 1 on error (set with yasm_error_set), 0 on success. */ -int yasm_bc_get_multiple(yasm_bytecode *bc, /*@out@*/ unsigned long *multiple, +int yasm_bc_get_multiple(yasm_bytecode *bc, /*@out@*/ long *multiple, int calc_bc_dist); /** Create a new data value from an expression.