* gas/i386/float.s, gas/i386/float.l: Modify to work correctly
[deliverable/binutils-gdb.git] / gas / flonum-mult.c
index 14fbd7d25f475435db4fa7893777b88b081d474f..434a73b0411ca9f98e3cea7aeeed8f9306fa199d 100644 (file)
@@ -18,6 +18,7 @@
    in a file named COPYING.  Among other things, the copyright
    notice and this notice must be preserved on all copies.  */
 
+#include <ansidecl.h>
 #include "flonum.h"
 
 /*     plan for a . b => p(roduct)
@@ -119,15 +120,11 @@ flonum_multip (a, b, product)
     }
   carry = 0;
   significant = 0;
-  for (N = 0;
-       N <= size_of_sum;
-       N++)
+  for (N = 0; N <= size_of_sum; N++)
     {
       work = carry;
       carry = 0;
-      for (A = 0;
-          A <= N;
-          A++)
+      for (A = 0; A <= N; A++)
        {
          B = N - A;
          if (A <= size_of_a && B <= size_of_b && B >= 0)
@@ -135,7 +132,11 @@ flonum_multip (a, b, product)
 #ifdef TRACE
              printf ("a:low[%d.]=%04x b:low[%d.]=%04x work_before=%08x\n", A, a->low[A], B, b->low[B], work);
 #endif
-             work += a->low[A] * b->low[B];
+             /* Watch out for sign extension!  Without the casts, on
+                the DEC Alpha, the multiplication result is *signed*
+                int, which gets sign-extended to convert to the
+                unsigned long!  */
+             work += (unsigned long) a->low[A] * (unsigned long) b->low[B];
              carry += work >> LITTLENUM_NUMBER_OF_BITS;
              work &= LITTLENUM_MASK;
 #ifdef TRACE
@@ -162,9 +163,9 @@ flonum_multip (a, b, product)
        }
     }
   /*
-        * [P]-> position # size_of_sum + 1.
-        * This is where 'carry' should go.
-        */
+   * [P]-> position # size_of_sum + 1.
+   * This is where 'carry' should go.
+   */
 #ifdef TRACE
   printf ("final carry =%04x\n", carry);
 #endif
@@ -180,9 +181,7 @@ flonum_multip (a, b, product)
          /* Shift right 1 to make room for most significant littlenum. */
          exponent++;
          P--;
-         for (q = product->low + P;
-              q >= product->low;
-              q--)
+         for (q = product->low + P; q >= product->low; q--)
            {
              work = *q;
              *q = carry;
This page took 0.023303 seconds and 4 git commands to generate.