Assembler:Commands:XCHG
Jump to navigation
Jump to search
command xchg destination, source
Exchange the contents of the source with the destination.
Exchanges the contents of the destination (first) and source (second) operands. The operands can be two general-purpose registers or a register and a memory location. If a memory operand is referenced, the processor's locking protocol is automatically implemented for the duration of the exchange operation, regardless of the presence or absence of the LOCK prefix or of the value of the IOPL. The XCHG instruction can also be used instead of the BSWAP instruction for 16-bit operands.
Command Parameters[edit]
Parameter | Description |
---|---|
destination | r8-m8 / r16-m16 / r32-m32 |
source | r8-m8 / r16-m16 / r32-m32 |
Examples[edit]
xchg dl,ah
xchg al,[edx+110] // byte value
xchg ax,dx
xchg [eax+10],dx // word value
xchg edx,eax
xchg [esi],edi // dword value