This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: problem in extended asm
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Ankit Jain <ankitjain1580 at yahoo dot com>
- Cc: gcc <gcc-help at gcc dot gnu dot org>
- Date: Mon, 09 Aug 2004 10:23:54 -0700
- Subject: Re: problem in extended asm
- References: <20040809171020.61634.qmail@web52901.mail.yahoo.com>
Ankit Jain <ankitjain1580@yahoo.com> writes:
> hi
>
> a simple question: why the followinf instruction
> dosent work in gcc
> for(i=0;i<8;i++)
> {
> asm("movq i(%1),%%mm0 \n"
> "movq %%mm0,(%0)
> :"=r"(x)
> :"r"(m)); //m is an array
> }
> for(i=0;i<8;i++)
> printf("%d",x[i])
This sort of question is appropriate for gcc-help only; cc: adjusted.
We cannot tell you exactly what is wrong when you provide only a code
fragment like this. However, I can tell you right now that referring
to "i" directly in the assembler, as you have done, does not work.
You need to treat _all_ variables as operands. Also you forgot to
clobber mm0. And did you really mean to index the access to x, but
not m?
I suspect (but cannot be sure, since you did not provide a complete
test case) that what you really want to write is something like
asm ("movq %1,%%mm0\n\t"
"movq %%mm0, %0"
: "=m" (x[i])
: "m" (m[i])
: "mm0");
If you really meant to index only x, not m, then you can write this
even simpler:
asm ("movq %1,%0" : "=m" (x[i]) : "y" (m[0]));
(a "y" constraint puts the value in an MMX register).
zw