Re: problem in extended asm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ankit Jain <ankitjain1580@xxxxxxxxx> 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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux