[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-dev] R1 after math. functions
From: |
Dmitry K. |
Subject: |
[avr-libc-dev] R1 after math. functions |
Date: |
Mon, 4 Oct 2004 15:38:54 +1100 |
User-agent: |
KMail/1.5 |
See `avr-libc Buglist' about this error.
The mathematical library avr-libc (version 1.0.4 and earlier) can leave
the register 'r1' noncleaned. It occurs by a call of some functions (in
particular cos, tan) to argument which is not usual float point number.
It is possible to make sure in it on the following example:
extern double tan (double); /* no math.h, to exclude const attr. */
int main ()
{
unsigned char r1;
union {
unsigned long lo;
double fl;
} x;
x.lo = 0x7f800000;
tan(x.fl);
asm ("mov %0,r1" : "=r"(r1));
return r1;
}
The reason consists in function __fp_split (more precisely a set of
functions). Having found an invalid number, it deletes 2 bytes from a
stack and jumps on 'ret' on earlier address of return. Thus performance
__fp_merge which, among other things, should null r1 is excluded.
Corrects a mistake addition of the instruction `clr r1' in `fp_split.S'
on a place of emergency return:
diff -Naur avr-libc-1.0.4.orig/libm/fplib/fp_split.S
avr-libc-1.0.4/libm/fpli
--- avr-libc-1.0.4.orig/libm/fplib/fp_split.S 2002-07-05
20:38:44.0000
+++ avr-libc-1.0.4/libm/fplib/fp_split.S 2004-10-01 00:42:04.000000000
+0
@@ -76,6 +76,7 @@
#ifdef __ERRNO__
LDI rA3,EDOM ; NaN is argument domain error !
#endif
+ clr r1 /* 2004-10-01: added */
RJMP _U(__fp_nan)
ENDFUNC
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-dev] R1 after math. functions,
Dmitry K. <=