Xor swap algorithm/Assembler Code
Appearance
The following routine swaps the value in the AX register with the value in the BX register without using a temporary buffer.
XOR AX, BX XOR BX, AX XOR AX, BX
The Intel 80386 CPU also supports an XCHG instruction which does the same work on its operands more efficiently then the above routine. This instruction is not supported by the original 8086, 8088, 80186 and 80286 CPUs however.
See: Xor swap algorithm