[Icc-mot] fround problem / fp conversion
Richard Man
richard-lists at imagecraft.com
Wed Jan 30 01:23:47 PST 2008
As with Edward, I can't reproduce this problem. Whatever it is, I
don't think it's related to uint2fp or signed int to FP conversion..?
At 03:20 AM 1/23/2008, Edward Karpicz wrote:
>Both get_pressure2() variants seem to work me :-(. Do you have
>
>#include <math.h>
>
>in your code?
>
>
>Regarding your own fround:
>
>signed long fround(float data_in)
>{
>signed long data_out;
>if (data_in>0)
>{
> data_out=(signed long)(data_in+0.5);
>}
>return data_out;
>}
>
>1) when data_in is negative or zero, data_out is undefined
>2) if you included math.h, then it should complain about redefining
>fround. fround should return float, not signed long. BTW is fround a
>standard C function?
>3) without valid fround prototype you not only should get a warning
>about missing prototype, but also it's expected to hang. Functions
>returning longs and floats, such functions are pushing return value
>to the stack. Callee has to pull return value from stack. Without
>valid prototype, any function is assumed to be defined as int
>foo(int). It wouldn't hang if fround was returning
>int/short/char/void and signed variants of <=16bits wide return types.
>
>Also, is include path pointing to V7 include folder?
>
>Edward
>
>
>
>----- Original Message ----- From: "Rene Streubel"
><r.streubel at emtec-papertest.de>
>To: <icc-mot at imagecraft.com>
>Sent: Wednesday, January 23, 2008 12:19 PM
>Subject: [Icc-mot] fround problem / fp conversion
>
>
>I tried to reduce the function:
>If the function have to round an unsigned value, so it is OK:
>
>signed int get_pressure2(unsigned char p_ch)
>{
>return froundf(abs(-101.85));
>}
>
>But, if the function have to round a signed value, it crashes:
>
>signed int get_pressure2(unsigned char p_ch)
>{
>return froundf(-101.85);
>}
>
>I checked my Program Memory. I had a mistake in my email. The
>correct settings in my project are:
>Program Memory: 0x4000.0x7FFF:0xC000.0xEFFF
>My complete program needs pages 20..23 Is there a problem with the
>memory mapping?
>
>I wrote about my own fround function and that it crahes with the if
>statement inside.
>There is the same thing. If it is signed in the if statement it
>crashes. Without the if statement it not crashes. I think there is a
>problem with the signed fp conversion / emulation.
>
>Richard wrotes about the 7.03 Beta0 and that the compiler did not
>generate calls to "uint2fp" for unsigned to FP conversion. Maybe
>there is now a new bug with any conversion?
>
>What should I do?
>
>Rene
>
>
>
>-
// richard (This email is for mailing lists. To reach me directly,
please use richard at imagecraft.com)
More information about the Icc-mot
mailing list