This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problem with ARM port and pow() function


Hi Nick,

I've done some more tests with the newlib math functions with float arguments, 
GNU arm toolchain and ARM7 NXP LPC2106 microcontroller:

log        works
log10      works
sqrt       works
tan        Error (uncorrect result)
cos        Crash
sin        Crash
pow        Crash

As you can see, some functions work, other don't.

I noticed that the NOT working functions have the common feature that they 
call other newlib math internal functions in their code, while the correctly 
working functions do not have any call.

For example, tan() function calls for __kernel_tan(x,z,1) in one point of the 
source code.
I tracked down with arm-elf-insight the step-by-step flow of the program in 
the tan() function; here below an extract from it:
---------------------------------------------------------
        85 ...
 	86	#ifdef __STDC__
 	87		double tan(double x)
 	88	#else
 	89		double tan(x)
 	90		double x;
 	91	#endif
	92	{
 	93		double y[2],z=0.0;
 	94		__int32_t n,ix;
 	95	
 	96	    /* High word of x. */
-	97		GET_HIGH_WORD(ix,x);
 	98	
 	99	    /* |x| ~< pi/4 */
-	100		ix &= 0x7fffffff;
-	101		if(ix <= 0x3fe921fb) return __kernel_tan(x,z,1);
        102 ...
---------------------------------------------------------

When the execution reaches the line 101, I expect that the next step should 
continue at 102 or return back in the calling procedure, depending on the 
result of "if(ix <= 0x3fe921fb)".

But this is NOT what happens: the execution after line 101 go back to line 
100!

I've also just in this moment tested another toolchain, this time not for 
linux but for windows: the YAGARTO toolchain. I have the same results for 
pow() function, which cause a crash also with this toolchain. The crash is 
for "undefined instruction".

If you have any suggestion, I will appreciate it...


Thank you,

Fausto


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]