From owner-freebsd-hackers Wed Dec 13 14:51:49 2000 From owner-freebsd-hackers@FreeBSD.ORG Wed Dec 13 14:51:46 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from kwanon.research.canon.com.au (kwanon.research.canon.com.au [203.12.172.254]) by hub.freebsd.org (Postfix) with ESMTP id 4E83237B69B for ; Wed, 13 Dec 2000 14:51:46 -0800 (PST) Received: from bellmann.research.canon.com.au (bellmann.research.canon.com.au [10.5.0.3]) by kwanon.research.canon.com.au (Postfix) with ESMTP id 772F78A898; Wed, 13 Dec 2000 22:54:43 +0000 (UTC) Received: from elph.research.canon.com.au (elph.research.canon.com.au [203.12.174.253]) by bellmann.research.canon.com.au (Postfix) with ESMTP id 9EB928B10; Thu, 14 Dec 2000 09:41:43 +1100 (EST) Received: from blow.research.canon.com.au (blow.research.canon.com.au [10.8.1.4]) by elph.research.canon.com.au (Postfix) with ESMTP id 095583C8; Thu, 14 Dec 2000 09:51:02 +1100 (EST) Date: Thu, 14 Dec 2000 09:51:42 +1100 (EST) From: Iain Templeton To: freebsd-hackers@FreeBSD.ORG Cc: Alfred Perlstein , Drew Eckhardt , Marc Tardif Subject: Re: syscall assembly In-Reply-To: <20001213142539.R16205@fw.wintelcom.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, 13 Dec 2000, Alfred Perlstein wrote: > David, can you look at this? > > #include > > int foo() { > open("file", O_RDONLY); > return 0; > } > int main() { > int x; > x = foo(); > return 0; > } > > results in: > > foo: > pushl %ebp > movl %esp,%ebp > subl $8,%esp > addl $-8,%esp > pushl $0 > pushl $.LC0 > call open > xorl %eax,%eax > leave > ret > > why the subl then addl? > Well, as a thoroughly rough guess, the subl is probably to create space on the stack for the args, and the addl is to align the stack to a 16 byte address? I know that the PowerPC ABI wants that, but no idea about x86. Iain To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message