Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inline assembly SSE Instruction with GNU Compiler

Status
Not open for further replies.

fredwurst

Programmer
Jul 4, 2003
1
DE
Hello,

This simple program (below) compiles and runs, but it does not work correctly. The output I get is
> nan 2 3 4
but I should get something like
> 2 3 1 4

Why that ???
(Compiled with GNU Compiler GCC 2.96 and 3.2 ...)

Thanks for help,
Fredwurst



#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
float vec1[4] = {1,2,3,4};
float vec2[4];

__asm__ __volatile__ (&quot;
movaps %1, %%xmm0;
pshufd $0x78, %%xmm0, %%xmm1;
movaps %%xmm0, %0;
&quot;
: &quot;=m&quot;(vec2[0])
: &quot;m&quot;(vec1[0])
);

cout << vec2[0] << &quot; &quot; << vec2[1] << &quot; &quot; <<
vec2[2] << &quot; &quot; << vec2[3] << endl;

return 0;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top