why does it use the movl instead of push ?!

Posted by user554403 on Stack Overflow See other posts from Stack Overflow or by user554403
Published on 2010-12-26T17:42:35Z Indexed on 2010/12/26 17:54 UTC
Read the original article Hit count: 129

Filed under:
|
|

hi all. pay attention to this code :

#include <stdio.h>
void a(int a, int b, int c)
{
    char buffer1[5];
    char buffer2[10];
}

int main()
{
    a(1,2,3); 
}

after that :

gcc -S a.c

that command shows our source code in assembly.

now we can see in the main function, we never use "push" command to push the arguments of the a function into the stack. and it used "movel" instead of that

main:
 pushl %ebp
 movl %esp, %ebp
 andl $-16, %esp
 subl $16, %esp
 movl $3, 8(%esp)
 movl $2, 4(%esp)
 movl $1, (%esp)
 call a
 leave

why does it happen? what's difference between them?

© Stack Overflow or respective owner

Related posts about c

    Related posts about assembly