Mail Archives: djgpp/1998/09/10/20:15:43
From: | Endlisnis <s257m AT unb DOT ca>
|
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: | <m0zHArk-000S5AC AT inti DOT gov DOT ar>
|
NNTP-Posting-Host: | fctnts13c40.nbnet.nb.ca
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
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
- Raw text -