x86 128 位原子操作

发布于 2024-09-30 15:07:02 字数 289 浏览 1 评论 0原文

如何在 x86 中实现 128 位原子操作?

Intel 的系统编程指南,第 1 部分,8.1 锁定原子操作指定了有保证的 16 位、32 位和 64 位原子操作。那么,可以通过执行 2 个带有 LOCK 前缀的 64 位操作来实现 128 位原子操作吗?就像...

LOCK mov 64bits->addr
LOCK mov 64bits->addr+64bits

显然 SSE 有 128 位 XMM 寄存器。您可以使用这些寄存器进行 128 位比较和交换吗?

How would you achieve 128-bit atomic operations in x86?

Intel's System Programming Guide, Part 1, 8.1 Locked Atomic Operations specifies guaranteed 16-, 32-, and 64-bit atomic operations. So, can you achieve 128-bit atomic operations by doing 2 64-bit ops with the LOCK prefix? Something like...

LOCK mov 64bits->addr
LOCK mov 64bits->addr+64bits

Aparently SSE has 128-bit XMM registers. Can you just do 128-bit compare-and-swap using these registers?

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

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

发布评论

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

评论(1

清风不识月 2024-10-07 15:07:02

LOCK 前缀不能与MOV 指令结合使用。

LOCK 前缀只能添加到以下指令之前,并且只能添加到目标操作数是内存操作数的指令形式:ADD、ADC、AND、BTC、BTR、BTS、CMPXCHG、CMPXCH8B、DEC、INC 、NEG、NOT、OR、SBB、SUB、XOR、XADD 和 XCHG。 英特尔指令集参考

这样做会生成无效操作码异常。所以LOCK CMPXCHG16B是这里唯一的方法。

The LOCK Prefix can not be used in combination with MOV instruction.

The LOCK prefix can be prepended only to the following instructions and only to those forms of the instructions where the destination operand is a memory operand: ADD, ADC, AND, BTC, BTR, BTS, CMPXCHG, CMPXCH8B, DEC, INC, NEG, NOT, OR, SBB, SUB, XOR, XADD, and XCHG. Intel Instruction Set Reference

Doing so will generate an Invalid Opcode Exception. So LOCK CMPXCHG16B is the only way here.

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