[linux-audio-dev] [i686] xmm regs + gcc inline assembly

Simon Jenkins sjenkins at blueyonder.co.uk
Thu Feb 12 22:00:51 UTC 2004


Tim Goetze wrote:

>can anybody help out with gcc inline assembly syntax applied to sse
>registers/memory locations?
>
>for a simplified example, i'm using
>
>  float t[4];
>  ...
>  asm ("movaps %%xmm1, %0" : : "m" (t[0]));
>
>to move 4 packed floats from xmm1 into 't'.
>
I couldn't get this to fail in practice - though I didn't
try all that hard - unless t isn't on a  16 byte boundary
in which case it segfaults.

In theory however your code is telling the compiler that
array element t[0] is in memory from which the instruction
reads. It should be more like:

    asm ("movaps %%xmm1 %0" : "=m" (t) );

which now tells the compiler that the entire array t
is in memory to which the instruction writes. This
*ought* to discourage the optimiser from doing
anything too drastic. (Maybe/AFAIK/IANAL/etc).

Simon Jenkins
(Bristol, UK)





More information about the Linux-audio-dev mailing list