XCHG
Usage: XCHG dest,src Modifies flags: None
Exchanges contents of source and destination.
Exchange
XCHG reg8,r/m8 ; 86 /r [8086]
XCHG reg16,r/m8 ; o16 87 /r [8086]
XCHG reg32,r/m32 ; o32 87 /r [386]
XCHG r/m8,reg8 ; 86 /r [8086]
XCHG r/m16,reg16 ; o16 87 /r [8086]
XCHG r/m32,reg32 ; o32 87 /r [386]
XCHG AX,reg16 ; o16 90+r [8086]
XCHG EAX,reg32 ; o32 90+r [386]
XCHG reg16,AX ; o16 90+r [8086]
XCHG reg32,EAX ; o32 90+r [386]
XCHG exchanges the values in its two operands. It can be used with a LOCK prefix for purposes of multi-processor synchronization.
XCHG EAX,EAX generates the opcode 90h, and so is a synonym for NOP.
EXAMPLE:
mov ebx 25 | mov ecx 10
sub ebx ecx
xchg ecx ebx ; ecx = 15