A simple question

Chungwei Hsiung skuma17 at yahoo.com
Fri Mar 5 12:41:15 PST 2004


ISAAC GELADO FERNANDEZ wrote:

>De: Chungwei Hsiung <skuma17 at yahoo.com>
>Fecha: Viernes, Marzo 5, 2004 7:43 pm
>  
>
>>I have a simple test program. I compile it, 
>>and 
>>gdb to disassemble main. I got the following..
>>
>>0x80481f8 <main>:       push   %ebp
>>0x80481f9 <main+1>:     mov    %esp,%ebp
>>0x80481fb <main+3>:     sub    $0x8,%esp
>>0x80481fe <main+6>:     and    $0xfffffff0,%esp
>>0x8048201 <main+9>:     mov    $0x0,%eax
>>0x8048206 <main+14>:    sub    %eax,%esp
>>
>>I don't know if at line 5, we move zero to %eax. why do we need to sub %eax, %esp? why do we need to subtract 0 from the stack pointer??
>>    
>>
> 
> I am no really sure, but it maybe be because you don't have any local variable, so it is no necessary to allocate memory in the stack for them. This seems a pattern from the compiler, it subtract the size of local variables from the stack pointer, so when there is none it subtracts zero. But this is just a supposition
> 
> Regards,
> Isaac
>
>
>_______________________________________________
>freebsd-hackers at freebsd.org mailing list
>http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
>To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>
>  
>



More information about the freebsd-hackers mailing list