Date: Fri, 05 Mar 2004 21:07:10 +0100 From: ISAAC GELADO FERNANDEZ <igf@tid.es> To: freebsd-hackers@freebsd.org Subject: Re: A simple question Message-ID: <2ccf552c8dcf.2c8dcf2ccf55@tid.es>
next in thread | raw e-mail | index | archive | help
De: Chungwei Hsiung <skuma17@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2ccf552c8dcf.2c8dcf2ccf55>