Message-Id: Comments: Authenticated sender is From: "Salvador Eduardo Tropea (SET)" Organization: INTI To: Endlisnis , djgpp AT delorie DOT com Date: Wed, 9 Sep 1998 09:59:09 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: Bug in GCC? In-reply-to: <35F5B07A.8E37D184@unb.ca> Precedence: bulk Endlisnis wrote: > Eli Zaretskii wrote: > > > > On Mon, 7 Sep 1998, Endlisnis wrote: > > > > > > * Post the complete asm produced. > > > I don't know how to do that. > > > > Add -S to the compilation switches. > > OK, Here is the input file, which seems to compile differently when giving asm > output, but it still isn't right! And included is the complete asm output, I > marked the place where it screws up, in the add function. Is there something > I'm doing wrong? > > #include > > int add(int a, int b) > { > int Ret; > asm ("addl %1, %0" //this line compiles to "addl ecx,ecx". > : "=&r" (Ret) > : "0" (a), "r" (b) > ); > return Ret; > } I guess that's just an example, no? There is no need for such a routine. Anyways ... it doesn't look right try it: int add(int a,int b) { int ret; asm ("movl %2,%0; addl %1,%0" : "rm="(ret) : "r"(b), "r"(a)); return ret; } Compiled with -O2 gives .file "p.c" gcc2_compiled.: ___gnu_compiled_c: .text .p2align 2 .globl _add _add: pushl %ebp movl %esp,%ebp movl 12(%ebp),%edx movl 8(%ebp),%ecx /APP movl %ecx,%eax; addl %edx,%eax /NO_APP leave ret But again isn't a good idea a rotine to make just a simple add because gcc will do it pretty well alone. SET ------------------------------------ 0 -------------------------------- Visit my home page: http://set-soft.home.ml.org/ or http://www.geocities.com/SiliconValley/Vista/6552/ Salvador Eduardo Tropea (SET). (Electronics Engineer) Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org ICQ: 2951574 Address: Curapaligue 2124, Caseros, 3 de Febrero Buenos Aires, (1678), ARGENTINA TE: +(541) 759 0013