> ISAAC GELADO FERNANDEZ wrote:
> 
> >De: Chungwei Hsiung <[EMAIL PROTECTED]>
> >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
> > 
> >
> >
> thank you for the reply..
> I try it again to call a function with local variables, but it does 
> that 
> as well. I think that line is not a part of a function prologue 
> because 
> when I try it with or without local variables, it is always there. 
> any 
> ideas??
> btw.. the compiler I use is gcc 3.2.2


I have performed some tests and the "strange" code apperars always. 

At first I thought the compiler puts the code to align the stack, but if you write a 
function it doesn't appear.

Maybe the compiler puts the subl to set system flags to a known value, but I don't 
really know.

I will try to obtain a good answer, I am really intrigate ;)

Regards,
 Isaac

> 
> best regards
> Chungwei
> 

_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to