This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: where does gcc generate float param passing code be
- From: "add" <addsub at eyou dot com>
- To: eljay at adobe dot com, addsub at eyou dot com, gcc-help at gcc dot gnu dot org
- Date: 7 Feb 2004 11:46:03 +0800
- Subject: Re: where does gcc generate float param passing code be
- Reply-to: "add" <addsub at eyou dot com>
sorry for my testcase, I had rewriten it to easy to understand, but on the
contrary...
Here is my true test case using printf:
----main.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
float i=1.0;
printf("%f",i);
return 0;
}
----main.c
here is generated by arm-linux-gcc -S main.c -o main.s
----main.s
<sniz>
main:
@ args = 0, pretend = 0, frame = 4
@ frame_needed = 1, uses_anonymous_args = 0
mov ip, sp
stmfd sp!, {r4, fp, ip, lr, pc}
sub fp, ip, #4
sub sp, sp, #4
ldr r3, .L2 @ float
str r3, [fp, #-20] @ float
ldr r0, [fp, #-20] @ float
bl __extendsfdf2
mov r4, r1
mov r3, r0
ldr r0, .L2+4
mov r2, r4
mov r1, r3
bl printf
mov r3, #0
mov r0, r3
<sniz>
-----main.s
if I arm-linux-gcc main.s -o test
then execute test on pxa board, it will output: -1.999744
but if I modified the two lines before "bl printf" in main.s to:
mov r2, r3
mov r3, r4
then compile main.s and execute,
it will print right result: 1.00000
so conclusion:
my toolchain must has a problem of float param passing, so I want to dig into
my gcc source tree to find where is responsible for generating this wrong asm
code.
I hope this time it's clearer :)
>Hi add,
>
>What we have here is "GIGO". Garbage in, garbage out.
>
>Try this instead:
>- - - - - - - - - - - - - - - -
>double foo( double i )
>{
> return i;
>}
>int main()
>{
> double i=1.0;
> foo(i);
> return 0;
>}
>- - - - - - - - - - - - - - - -
>
>Note all the differences, there are quite a few. Order is important.
Details are important.
>
>HTH,
>--Eljay
>
>
--http://www.eyou.com
--Îȶ¨¿É¿¿µÄµç×ÓÐÅÏä ÓïÒôÓʼþ Òƶ¯ÊéÇ© ÈÕÀú·þÎñ ÍøÂç´æ´¢...ÒÚÓÊδ¾¡
--http://vip.eyou.com
--¿ì¿ìµÇ¼ÒÚÓÊVIPÐÅÏä ×¢²áÄúÖÐÒâµÄÓû§Ãû