我在GCC写入C中的应用(用于Linux / Ubuntu的),其使用下列联汇编

float a[4] = { 10, 20, 30, 40 };
float b[4] = { 0.1, 0.1, 0.1, 0.1 };

asm volatile("movups (%0), %%xmm0\n\t"
             "mulps (%1), %%xmm0\n\t"
             "movups %%xmm0, (%1)"
             :: "r" (a), "r" (b));

在上面的借口错别字(我是从存储器写入)。什么是在Visual C ++ 6.0相当于内嵌汇编?我发现我需要移植我的代码。

有帮助吗?

解决方案

__declspec(align(16)) float a[4] = { 10, 20, 30, 40 };
__declspec(align(16)) float b[4] = { 0.1f, 0.1f, 0.1f, 0.1f };

__asm {
    movups xmm0, a; // could be movaps if array aligned
    mulps xmm0, b;
    movups b, xmm0; // could be movaps if array aligned
}

我不知道有关Visual C ++ 6,但它会在Visual C ++工作2008年。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top