X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device%2Flib%2F_fsadd.c;h=cb179c5e9644ccf75724580ac0226e478ab1b720;hb=d08e6df2202ed3f19b681221b502dedb3c6c8a28;hp=8d3c6ab3acd4cd9970139fdb0886e2e7cacd2851;hpb=bf1925f901a9f45ad2529874f41e1e2b01f5bc9f;p=fw%2Fsdcc diff --git a/device/lib/_fsadd.c b/device/lib/_fsadd.c index 8d3c6ab3..cb179c5e 100644 --- a/device/lib/_fsadd.c +++ b/device/lib/_fsadd.c @@ -23,10 +23,10 @@ #ifdef FLOAT_ASM_MCS51 -// float __fsadd (float a, float b) reentrant -static void dummy(void) _naked +// float __fsadd (float a, float b) __reentrant +static void dummy(void) __naked { - _asm + __asm // extract the two inputs, placing them into: // sign exponent mantiassa @@ -128,7 +128,7 @@ fsadd_direct_entry: lcall fs_normalize_a ljmp fs_round_and_return - _endasm; + __endasm; } #else @@ -150,7 +150,6 @@ fsadd_direct_entry: ** uunet!motown!pipeline!phw */ - union float_long { float f; @@ -163,7 +162,7 @@ float __fsadd (float a1, float a2) volatile long mant1, mant2; volatile union float_long fl1, fl2; volatile int exp1, exp2; - volatile unsigned long sign = 0; + char sign = 0; fl1.f = a1; fl2.f = a2; @@ -204,7 +203,7 @@ float __fsadd (float a1, float a2) if (mant1 < 0) { mant1 = -mant1; - sign = SIGNBIT; + sign = 1; } else if (!mant1) return (0); @@ -219,7 +218,7 @@ float __fsadd (float a1, float a2) while (mant1 & 0xff000000) { if (mant1&1) mant1 += 2; - mant1 >>= 1 ; + mant1 >>= 1; exp1++; } @@ -227,10 +226,13 @@ float __fsadd (float a1, float a2) mant1 &= ~HIDDEN; /* pack up and go home */ - fl1.l = PACK (sign, (unsigned long) exp1, mant1); - + if (exp1 >= 0x100) + fl1.l = (sign ? SIGNBIT : 0) | __INFINITY; + else if (exp1 < 0) + fl1.l = 0; + else + fl1.l = PACK (sign ? SIGNBIT : 0 , exp1, mant1); return (fl1.f); } #endif -