projects
/
fw
/
sdcc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* device/include/float.h: added __INFINITY
[fw/sdcc]
/
device
/
lib
/
_fsmul.c
diff --git
a/device/lib/_fsmul.c
b/device/lib/_fsmul.c
index 96be13d95c9c7267e1441972a41c89a786b82ece..1f36d603d97830dabfec4971afcb8d40ea97b06f 100644
(file)
--- a/
device/lib/_fsmul.c
+++ b/
device/lib/_fsmul.c
@@
-23,10
+23,10
@@
#ifdef FLOAT_ASM_MCS51
#ifdef FLOAT_ASM_MCS51
-// float __fsmul (float a, float b) reentrant
-static void dummy(void) _naked
+// float __fsmul (float a, float b)
__
reentrant
+static void dummy(void) _
_
naked
{
{
- _asm
+ _
_
asm
.globl ___fsmul
___fsmul:
// extract the two inputs, placing them into:
.globl ___fsmul
___fsmul:
// extract the two inputs, placing them into:
@@
-51,12
+51,32
@@
___fsmul:
cpl sign_a
00003$:
cpl sign_a
00003$:
- // add the exponents
+ // check if either input is infinity
+ mov a, exp_b
+ cjne a, #0xFF, 00004$
+ ljmp fs_return_inf
+00004$:
mov a, exp_a
mov a, exp_a
+ cjne a, #0xFF, 00005$
+ ljmp fs_return_inf
+00005$:
+
+ // add the exponents
add a, exp_b
add a, exp_b
+ // if carry then no underflow
+ jc 00006$
add a, #130
add a, #130
- mov exp_a, a
+ jc 00007$
+ ljmp fs_return_zero
+
+00006$:
+ add a, #131
+ dec a
+ jnc 00007$
+ ljmp fs_return_inf
+00007$:
+ mov exp_a, a
// now we need to multipy r4/r3/r2 * r7/r6/r5
// ------------------------------------------
// now we need to multipy r4/r3/r2 * r7/r6/r5
// ------------------------------------------
@@
-178,12
+198,11
@@
___fsmul:
00010$:
ljmp fs_round_and_return
00010$:
ljmp fs_round_and_return
- _endasm;
+ _
_
endasm;
}
#else
}
#else
-
/*
** libgcc support for software floating point.
** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
/*
** libgcc support for software floating point.
** Copyright (C) 1991 by Pipeline Associates, Inc. All rights reserved.
@@
-202,7
+221,6
@@
___fsmul:
/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
/* (c)2000/2001: hacked a little by johan.knol@iduna.nl for sdcc */
-
union float_long
{
float f;
union float_long
{
float f;
@@
-215,7
+233,7
@@
float __fsmul (float a1, float a2) {
volatile unsigned long result;
volatile int exp;
char sign;
volatile unsigned long result;
volatile int exp;
char sign;
-
+
fl1.f = a1;
fl2.f = a2;
fl1.f = a1;
fl2.f = a2;
@@
-252,9
+270,13
@@
float __fsmul (float a1, float a2) {
result &= ~HIDDEN;
/* pack up and go home */
result &= ~HIDDEN;
/* pack up and go home */
- fl1.l = PACK (sign ? SIGNBIT : 0 , (unsigned long)exp, result);
+ if (exp >= 0x100)
+ fl1.l = (sign ? SIGNBIT : 0) | __INFINITY;
+ else if (exp < 0)
+ fl1.l = 0;
+ else
+ fl1.l = PACK (sign ? SIGNBIT : 0 , exp, result);
return (fl1.f);
}
#endif
return (fl1.f);
}
#endif
-