From: Troy VanHorn Message-Id: <199809010109.UAA05151@snoopy.UCollege.edu> Subject: Re: passing arguments in registers To: GAMMELJL AT SLU DOT EDU Date: Mon, 31 Aug 1998 20:09:43 -0500 (CDT) Cc: trvanhor AT snoopy DOT UCollege DOT edu (Troy VanHorn), djgpp AT delorie DOT com In-Reply-To: <01J19GJU8Q9U94JXNE@SLU.EDU> from "GAMMELJL@SLU.EDU" at Aug "31," 1998 "06:04:28" pm MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk > The following C/C++ code when compiled: > gxx example9.cc -S -O2 > results in the .s file below it. It is plain that the arguments > of zadd are passed on the stack. Eli Zareteskii has told me that > passing them in registers requires > __attribute__((regparm=2)) Actually, you can make gcc pass up to three arguments in registers with __attribute__((regparm=3)). > and that the information about this is in the GCC docs. Please: > someone expert in searching these docs tell me exactly where this >attribute statement goes in the C++ code below and exactly what the >correct syntax is. _____The C/C++ source code_(Modified)______________________________ int zadd(int m,int n) __attribute__((regparm=3)); /* This should work */ int i,j,k; main() {i=2; /* ------> adds 2 and 3. */ j=3; k=zadd(i,j); return 0; } int zadd(int m,int n) /* --------> one wishes to place the attriute statement */ {return m+n;} /* in this subroutine */ ---------------- Troy Van Horn