Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22298

Why does gcc use movl instead of push to pass function args?

$
0
0

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?


Viewing all articles
Browse latest Browse all 22298

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>