On Wed, Feb 20, 2013 at 12:05:27AM -0600, Erik Petrich wrote:
> I can't answer most of your questions because I do use pic and so I am not
> very familiar with that part of SDCC. However, I can answer why SDCC does
> not need to call __fs2uint in the first example. SDCC's optimizations are
> all at the function level. It can see that x is assigned the float value
> 6116.0 and then debug is assigned a value from x. It sees that there are
> no intervening instructions that could modify x's value, therefor debug is
> assigned the value 6116.0 cast to unsigned int. This cast is being applied
> to a known constant, so the compiler performs this cast during compilation
> to avoid the overhead of calling __fs2uint during run-time.
Erik, This was great advice and very appreciated. Your explanations (I didn't
quote all of them) were quite helpful in narrowing down the problem a
bit more.
[...]
> void main(void) {
> volatile float x = 6116.0;
> debug = x;
> //debug is 6116.
> }
I now changed the code a bit (since my previous example added both,
fs2int and int2fs), to understand better what's going on:
long debug;
void main(void) {
long x = 100;
volatile float temp;
temp = x;
debug = temp; // debug=100 as expected
}
vs
long debug;
void main(void) {
volatile long x = 100;
float temp;
temp = x;
debug = temp; //debug=144, not expected
}
The asm block "functions called" is identical expect for the additional
"___slong2fs" in the not working example. I am not sure whether that is
sufficient indication to consider ___slong2fs the culprit, or whether I
can perform any additional tests.
When starting with 100 I obtain 144, for 116 I obtain 208, not sure that
this makes any sense. I guess it is time to look closer into slong2fs,
but I find different source files in the sdcc tree.
How can I know for sure which one is used here?
Why is it not the same for all chips?
Is there a way of making my debugging somewhat easier than connecting
displays to an actual chip?
Thanks for your help
//Daniel
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user