CMPXCHG compares the accumulator (AL, AX, or EAX) with a destination operand. If they are equal, the source operand is loaded into destination; otherwise, the destination operand is loaded into the accumulator.
This instruction is used to support semaphores.
Note On the A-step of the 486, CMPXCHG was microcoded using the opcodes for the, discarded, A- to B0-step 386 instructions XBTS (A6) and IBTS (A7). Because of software conflicts with software written for the early 386 DX, the opcodes for the 486 were changed to those shown below starting with the B step. Note that some 386 software won't run on older 386s and some 486 software will not run on early 486s when using this instruction.