From: Endlisnis Newsgroups: comp.os.msdos.djgpp Subject: Re: Not a bug in GCC. Was: Bug in GCC? Date: Thu, 10 Sep 1998 20:47:25 -0300 Organization: NBTel Internet Lines: 25 Message-ID: <35F8650D.D00F5779@unb.ca> References: NNTP-Posting-Host: fctnts13c40.nbnet.nb.ca Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Salvador Eduardo Tropea (SET) wrote: > > > int add(int a,int b) > > > { > > > int ret; > > > asm ("movl %2,%0; addl %1,%0" : "rm="(ret) : "r"(b), "r"(a)); > > > return ret; > > > } > > But, your requires an extra move! I actually found the problem in my code, > > not the compiler. > The move is needed, i386 chips doesn't support add mem,mem so you must move > to a register, explicitly or not (in the last case gcc does the move). No, you are moving from %2 (must be a register "r") to %0 (could be memory "rm="), which doesn make sence. It actually compiles to movl %ecx, %eax //useless code. addl %ebc, %eax > Good, but again: I hope that's just an example, you won't really use it, no? I was actually trying to teach someone asm, but the code didn't compile as I expected. -- (\/) Endlisnis (\/) s257m AT unb DOT ca Endlisnis AT GeoCities DOT com Endlis AT nbnet DOT nb DOT ca