not using push by gcc

Martin Sebor msebor@redhat.com
Fri Feb 6 16:51:00 GMT 2015


On 02/02/2015 01:15 AM, Mr.reCoder wrote:
> Dear gcc developer,
>
> I have a code like this:
>
> #include <stdio.h>
> void foo(int x)
> {
>    int y;
>    x++;
>    y = 4;
> }
> int main(void)
> {
>    foo(2);
>    return 0;
> }
>
> and compiled with "gcc -o outexec srcfile.c" command.
> when disassemble the file we see that sending argument to function
> "foo" is done by
>
> --------------------------------------
> sub     esp, 4
> mov     dword ptr [esp], 2
> call    foo
> --------------------------------------
>
> instructions. why gcc doesn't use the "push" command like:

You can find a discussion on the same subject here:

http://stackoverflow.com/questions/4534791/why-does-it-use-the-movl-instead-of-push

A recent GCC does as you suggest, so the version you're using
might be either too old or buggy. I see -mpush-args documented
as enabled by default as far back as 3.0.

Martin



More information about the Gcc mailing list