not using push by gcc

Mr.reCoder mr.recoder@gmail.com
Mon Feb 2 08:15:00 GMT 2015


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:

--------------------------------------
push 2
call    foo
--------------------------------------

?

Sincerely.



More information about the Gcc mailing list