FLOATING POINT FIXES (FSCALE, 0x1FD)
authorIshii Masahiro <ishii@kmc.kyoto-u.ac.jp>
Sat, 19 Sep 1992 00:00:00 +0000 (00:00 +0000)
committerIshii Masahiro <ishii@kmc.kyoto-u.ac.jp>
Sat, 19 Sep 1992 00:00:00 +0000 (00:00 +0000)
This is actually two patches in one.  It fixes the Floating Point
Emulation in two places.  The first is for the 0x1fd instruction; the
second is in Fscale.  It is believed to fix the atof() function, among
others, which normally fails on non-FPU machines.

AUTHOR: Ishii Masahiro, R. Kym Horsell
386BSD-Patchkit: patch00046

usr/src/sys.386bsd/i386/i386/math_emulate.c

index 8c6b093..e33b51a 100644 (file)
  * The other files also don't care about ST(x) etc - they just get addresses
  * to 80-bit temporary reals, and do with them as they please. I wanted to
  * hide most of the 387-specific things here.
  * The other files also don't care about ST(x) etc - they just get addresses
  * to 80-bit temporary reals, and do with them as they please. I wanted to
  * hide most of the 387-specific things here.
+ *
+ * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
+ * --------------------         -----   ----------------------
+ * CURRENT PATCH LEVEL:         1       00046
+ * --------------------         -----   ----------------------
+ *
+ * 19 Sep 92   Ishii Masahiro          Fix 0x1fd instruction
+ *             kym@bingsuns.cc.binghamton.edu          Fix fscale
  */
 
 #include "machine/cpu.h"
  */
 
 #include "machine/cpu.h"
@@ -163,7 +171,7 @@ math_emulate(struct trapframe * info)
                        /* incomplete and totally inadequate -wfj */
                        Fscale(PST(0), PST(1), &tmp);
                        real_to_real(&tmp,&ST(0));
                        /* incomplete and totally inadequate -wfj */
                        Fscale(PST(0), PST(1), &tmp);
                        real_to_real(&tmp,&ST(0));
-                       /* fall into .. */
+                       return(0);                      /* 19 Sep 92*/
                case 0x1fc:
                        frndint(PST(0),&tmp);
                        real_to_real(&tmp,&ST(0));
                case 0x1fc:
                        frndint(PST(0),&tmp);
                        real_to_real(&tmp,&ST(0));
@@ -1387,6 +1395,10 @@ void Fscale(const temp_real *a, const temp_real *b, temp_real *c)
        temp_int ti;
 
        *c = *a;
        temp_int ti;
 
        *c = *a;
+       if(!c->a && !c->b) {                            /* 19 Sep 92*/
+               c->exponent = 0;
+               return;
+       }
        real_to_int(b, &ti);
        if(ti.sign)
                c->exponent -= ti.a;
        real_to_int(b, &ti);
        if(ti.sign)
                c->exponent -= ti.a;