This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: not using push by gcc


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


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