0

The following code:

simd(n, is)
long *is;
{   
   long i;
   asm("pxor %mm0,%mm0");
   for (i = 0; i < n; i += W) {

       asm("movq %0 %%mm1\n\t"
           "paddq %%mm1 %%mm0"
           :
           :"m"(is[i])          );

   }
   return 0;
}

I'm unable to understand why it fails to compile with the following error:

/tmp/ccrDnFTm.s: Assembler messages:
/tmp/ccrDnFTm.s:29: Error: suffix or operands invalid for `movq'
/tmp/ccrDnFTm.s:30: Error: junk `%mm0' after register

Why?

MarZalazar
  • 35
  • 4
  • 2
    Why are you still writing code that uses MMX in this day and age? It's an incredibly outdated instruction set; unless you have a very good reason you should be using SSE instead. – Stephen Canon Jan 16 '13 at 21:48
  • 1
    @StephenCanon: Code will run in an industrial control system that uses an old Pentium processor. Changing the hardware was an option but the motherboard has custom peripherals (Analog I/O) that would be expensive replicate. – MarZalazar Jan 16 '13 at 21:54
  • 2
    Good, that's a rare good reason. Be sure to issue the EMMS instruction after doing any computations using MMX so that the x87 state is reset. Failing to do so is a common cause of extremely hard-to-diagnose bugs. – Stephen Canon Jan 16 '13 at 22:03

1 Answers1

4

Operands must be separated by commas:

movq %0, %%mm1
istepaniuk
  • 4,016
  • 2
  • 32
  • 60