From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13412 invoked by alias); 24 Apr 2004 02:20:15 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 13405 invoked from network); 24 Apr 2004 02:20:14 -0000 Received: from unknown (HELO yosemite.airs.com) (209.128.65.135) by sources.redhat.com with SMTP; 24 Apr 2004 02:20:14 -0000 Received: (qmail 13658 invoked by uid 10); 24 Apr 2004 02:20:13 -0000 Received: (qmail 13652 invoked by uid 500); 24 Apr 2004 02:20:04 -0000 From: Ian Lance Taylor To: Cezar Harabula Cc: gcc-help@gcc.gnu.org Subject: Re: C calling conventions: how to pass a struct parameter? References: <4087FAC0.5050502@open-plug.com> <6.0.3.0.2.20040422125050.01f9df58@iplan-mn.corp.adobe.com> <4088C829.6000307@open-plug.com> Date: Sat, 24 Apr 2004 02:20:00 -0000 In-Reply-To: <4088C829.6000307@open-plug.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-04/txt/msg00319.txt.bz2 Cezar Harabula writes: > Thank you for your answers. Unfortunately, I was not clear enough. I > want to know what happens in the registers and in the stack when a > procedure like > > void PrintFoo(struct Foo foo) > > is called. There is no universal C calling convention set for x86, so > I am interested in how GCC usually does. > > What about a struct return value: > struct bar Function() ? The easy way to find out is to write some code and look at the result when it is compiled using -S. The results will change if you use the -mregparm option. Structures are normally passed by pushing the value of the structure on the stack. Structures are normally returned by arranging for the caller to pass the address of a memory area as a hidden first argument. The function then stores the return value into that memory area. Ian