assembly - x86 128 位原子操作

标签 assembly x86 atomic x86-64

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

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

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

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

最佳答案

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

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

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

关于assembly - x86 128 位原子操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4099002/

相关文章:

assembly - 如何在 MIPS 中删除换行符?

assembly - 颜色 0-15 组装

c - 为什么 AVX-256 VMOVAPS 指令只复制四个单精度 float 而不是 8 个?

C缓冲区溢出攻击

rust - 为什么许多原始类型都有一个 `Atomic*` 类型而不是通用的 `Atomic<T>` 类型?

assembly - 如何在 assembly 中打印笑脸?

linux - x86 上的任务管理

linux - 如何在 x86 程序集中循环打印一个数字后的新行?

c++ - C++ 中的原子性 : Myth or Reality

c++ - boost::asio::io_service::post 是原子的吗?