Why gcc translate a c program into assemble as follow
- From: "Zheng Da" <spamtrap@xxxxxxxxxx>
- Date: Wed, 26 Oct 2005 17:52:05 +0000 (UTC)
A C function is like below:
void echo()
{
char buf[4];
gets(buf);
}
I use gcc compile it with the option -O2 -S, and get the following
assemble program:
echo:
pushl %ebp
movl %esp,%ebp
leal -4(%ebp),%eax
subl $20,%esp ##why allocate 20 bytes on stack? The variable in C
function is only 4 bytes
pushl %eax
call gets
leave
ret
.
- Follow-Ups:
- Re: Why gcc translate a c program into assemble as follow
- From: Tim Roberts
- Re: Why gcc translate a c program into assemble as follow
- From: wanderer83
- Re: Why gcc translate a c program into assemble as follow
- From: randyhyde@xxxxxxxxxxxxx
- Re: Why gcc translate a c program into assemble as follow
- Prev by Date: Re: compiler generated output
- Next by Date: Re: improve strlen
- Previous by thread: About instruction lea
- Next by thread: Re: Why gcc translate a c program into assemble as follow
- Index(es):