From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 5 12:07:12 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1ECEC16A4CE for ; Fri, 5 Mar 2004 12:07:12 -0800 (PST) Received: from correo.tid.es (tidos.tid.es [193.145.240.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id D6BF743D31 for ; Fri, 5 Mar 2004 12:07:11 -0800 (PST) (envelope-from igf@tid.es) Received: from conversion-daemon.tid.hi.inet by tid.hi.inet (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) id <0HU400L01CVFZL@tid.hi.inet> for freebsd-hackers@freebsd.org; Fri, 05 Mar 2004 21:07:10 +0100 (MET) Received: from tid.es (localhost [127.0.0.1]) by tid.hi.inet (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) with ESMTP id <0HU400CNTD7YVF@tid.hi.inet> for freebsd-hackers@freebsd.org; Fri, 05 Mar 2004 21:07:10 +0100 (MET) Received: from [213.9.244.25] by tid.hi.inet (mshttpd); Fri, 05 Mar 2004 21:07:10 +0100 Date: Fri, 05 Mar 2004 21:07:10 +0100 From: ISAAC GELADO FERNANDEZ To: freebsd-hackers@freebsd.org Message-id: <2ccf552c8dcf.2c8dcf2ccf55@tid.es> MIME-version: 1.0 X-Mailer: iPlanet Messenger Express 5.2 HotFix 1.18 (built Jul 28 2003) Content-type: text/plain; charset=us-ascii Content-language: es Content-transfer-encoding: 7BIT Content-disposition: inline X-Accept-Language: es Priority: normal Subject: Re: A simple question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Mar 2004 20:07:12 -0000 De: Chungwei Hsiung 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
: push %ebp > 0x80481f9 : mov %esp,%ebp > 0x80481fb : sub $0x8,%esp > 0x80481fe : and $0xfffffff0,%esp > 0x8048201 : mov $0x0,%eax > 0x8048206 : 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