"XCHG" may not be as efficient as it seems.For example, in x86 processors, "XCHG" will implicitly lock access to any operands in memory to ensure the operation is atomic, and so may not be efficient when swapping memory.