Search code examples
gccx86ssesimdmmx

Compile Error from x86 that uses MOVAPS


I'm getting a compile error of Error: operand type mismatch for 'movaps', and googling hasn't revealed a solution. movups and addps also give the same error.

Here's a relevant excerpt:

# load address into %eax
movaps %eax, %mm0

For completeness, I'm compiling the .s file with -m32.


Solution

  • You are missing a level of indirection on the first argument, and the second argument needs to be an XMM register (i.e. 128 bit SSE), not an MM register (old 64 bit MMX):

    movaps (%eax), %xmm0
    

    If you can use intrinsics in C or C++ rather than writing raw asm then you can do this kind of thing a lot more easily, e.g.

    __m128 v = _mm_load_ps(ptr);