projects
/
fw
/
sdcc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* device/include/pic16/pic18f25j10.h,
[fw/sdcc]
/
device
/
lib
/
expf.c
diff --git
a/device/lib/expf.c
b/device/lib/expf.c
index 9de01976b703589c2471d88402c4476234a18d35..a1355e8b496cee8c35597a1a0aadb766c2940f25 100644
(file)
--- a/
device/lib/expf.c
+++ b/
device/lib/expf.c
@@
-33,15
+33,15
@@
#include <float.h>
// TODO: share with other temps
#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;
float expf(float x)
{
x;
- _asm
+ _
_
asm
mov c, acc.7
mov _sign_bit, c // remember sign
clr acc.7 // and make input positive
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:
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
// 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:
dec sp
dec sp
expf_done:
- _endasm;
+ clr acc.7 // Result is always positive!
+ __endasm;
#pragma less_pedantic
}
#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
.globl fs_lshift_a
expf_scale_and_add:
push ar0
@@
-269,12
+268,12
@@
expf_scale_and_add:
dec sp
dec sp
ret
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
.globl fs_lshift_a
fs_lshift_a:
jz fs_lshift_done
@@
-298,14
+297,11
@@
fs_lshift_loop:
pop ar0
fs_lshift_done:
ret
pop ar0
fs_lshift_done:
ret
- _endasm;
+ _
_
endasm;
}
}
-
-
#else // not MATH_ASM_MCS51
#else // not MATH_ASM_MCS51
-
#define P0 0.2499999995E+0
#define P1 0.4160288626E-2
#define Q0 0.5000000000E+0
#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 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) */
#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;
if(sign)
{
errno=ERANGE;
- return XMAX;
+ return HUGE_VALF
+ ;
}
else
{
}
else
{
@@
-367,4
+364,3
@@
float expf(const float x)
}
#endif
}
#endif
-