* device/include/pic16/pic18f*.h: add bit aliases in INTCONbits_t
[fw/sdcc] / device / lib / expf.c
index 9de01976b703589c2471d88402c4476234a18d35..a1355e8b496cee8c35597a1a0aadb766c2940f25 100644 (file)
 #include <float.h>
 
 // TODO: share with other temps
-static bit sign_bit;
-static data unsigned char expf_y[4];
-static data unsigned char n;
+static __bit sign_bit;
+static __data unsigned char expf_y[4];
+static __data unsigned char n;
 
 
 float expf(float x)
 {
        x;
-       _asm
+       __asm
        mov     c, acc.7
        mov     _sign_bit, c    // remember sign
        clr     acc.7           // and make input positive
@@ -108,7 +108,7 @@ expf_range_ok:
        mov     r3,#0x39
        lcall   expf_scale_and_add
 expf_no_range_reduction:
-       
+
 
 // Compute e^x using the cordic algorithm.  This works over an
 // input range of 0 to 0.69314712.  Can be extended to work from
@@ -233,15 +233,14 @@ exp_cordic_skip:
        dec     sp
        dec     sp
 expf_done:
-       _endasm;
+       clr     acc.7           // Result is always positive!
+       __endasm;
 #pragma less_pedantic
 }
 
-
-
-static void dummy1(void) _naked
+static void dummy1(void) __naked
 {
-       _asm
+       __asm
        .globl  fs_lshift_a
 expf_scale_and_add:
        push    ar0
@@ -269,12 +268,12 @@ expf_scale_and_add:
        dec     sp
        dec     sp
        ret
-       _endasm;
+       __endasm;
 }
 
-static void dummy(void) _naked
+static void dummy(void) __naked
 {
-       _asm
+       __asm
        .globl  fs_lshift_a
 fs_lshift_a:
        jz      fs_lshift_done
@@ -298,14 +297,11 @@ fs_lshift_loop:
        pop     ar0
 fs_lshift_done:
        ret
-       _endasm;
+       __endasm;
 }
 
-
-
 #else // not MATH_ASM_MCS51
 
-
 #define P0      0.2499999995E+0
 #define P1      0.4160288626E-2
 #define Q0      0.5000000000E+0
@@ -317,7 +313,7 @@ fs_lshift_done:
 #define C1       0.693359375
 #define C2      -2.1219444005469058277e-4
 
-#define BIGX    88.72283911  /* ln(XMAX) */
+#define BIGX    88.72283911  /* ln(HUGE_VALF) */
 #define EXPEPS  1.0E-7       /* exp(1.0E-7)=0.0000001 */
 #define K1      1.4426950409 /* 1/ln(2) */
 
@@ -339,7 +335,8 @@ float expf(const float x)
         if(sign)
         {
             errno=ERANGE;
-            return XMAX;
+            return HUGE_VALF
+            ;
         }
         else
         {
@@ -367,4 +364,3 @@ float expf(const float x)
 }
 
 #endif
-