]> granicus.if.org Git - yasm/commitdiff
Allow multiples to become temporarily negative during optimization.
authorPeter Johnson <peter@tortall.net>
Sun, 4 Feb 2007 00:34:28 +0000 (00:34 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 4 Feb 2007 00:34:28 +0000 (00:34 -0000)
Negative multiples are still checked for during output.

svn path=/trunk/yasm/; revision=1752

libyasm/bc-int.h
libyasm/bytecode.c
libyasm/bytecode.h

index 66f22a211208fbbf1d11c2b36dfc9dbbfed2eee1..5bcd22e3fd9d63f542612529b4fd2a33155ef05d 100644 (file)
@@ -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;
index 59c93b28b92cbafea22bf7d659749a48439da518..7fe31be855b7eeb243ff15b3a18e69836cf17d1d 100644 (file)
@@ -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;
 }
index 0c406ef19085150cd3c306cfbe0d6692bfde7148..e26b901785dbc6eaf7917a304bdb0a31f4791d2e 100644 (file)
@@ -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.