CMPXCHG.htm
Command: CMPXCHG - Compare and Exchange
Arguments: DEST: general-purpose register or memory location; SRC: general-purpose register
Usage: CMPXCHG DEST, SRC
Effects: if (EAX/AX/AL=DEST) then dest:=src else EAX/AX/AL:=dest; If EAX/AX/AL (according to the size of the arguments) and DEST are equal, SRC is copied to DEST, otherwise DEST is copied to EAX/AX/AL.
Flags to be set: ZF is set if (EAX/AX/AL=DEST). CF, PF, AF, SF, and OF are set according to the results of the comparison.
Misc: Both arguments have to be of the same size.