Skip to content

FETCHXCHG

Operation

Atomically exchanges a register with memory and returns the old memory value.

Assembler Syntax

FETCHXCHG.{B|W|L|Q}(z)/order(o) Rn(s), <ea>(e)

Privilege

Unprivileged

Required CPUID flags

FETCHXCHG

Atomically replaces the selected-width memory value with the original source-register value and returns the old memory value in that register. The encoded memory-order selector governs the complete read-modify-write operation. Unlike the memory form of XCHG, this instruction is one atomic memory operation.

2.75in

Encodings

FETCHXCHG.{B|W|L|Q}(z)/order(o) Rn(s), <ea>(e)

Format: Instruction format for FETCHXCHG.{B|W|L|Q}(z)/order(o) Rn(s), <ea>(e)

Format: Instruction format for FETCHXCHG.{B|W|L|Q}(z)/order(o) Rn(s), <ea>(e)

orderallowed: 0x0..0x4 [memory_order_reserved_reclaimed]

memoryexcluded: immediate [memory_operand_required]