This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem in extended asm


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]