如何在 Visual C 中编写以下内联汇编代码 6.0?

发布于 2024-07-28 23:24:21 字数 378 浏览 1 评论 0原文

我正在 GCC(适用于 Linux/Ubuntu)中用 C 编写一个应用程序,它使用以下内联汇编。

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 中等效的内联汇编程序是什么? 我发现我需要移植我的代码。

I am writing an application in C in GCC (for Linux/Ubuntu) that uses the following inline assembly.

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));

Excuse typos in the above (I'm writing from memory). What is the equivalent inline assembler in Visual C++ 6.0 ? I have discovered that I need to port my code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爺獨霸怡葒院 2024-08-04 23:24:21
__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 中工作。

__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
}

I'm not sure about Visual C++ 6, but it will work in Visual C++ 2008.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文