<<< XCHG Instruction, Exchanging Integers | Index | Memory-to-memory exchange >>> |
In array sorting applications, XCHG provides a simple way to exchange two array elements.
Few more examples using XCHG:
xchg ax, bx ; exchange 16-bit regs xchg ah, al ; exchange 8-bit regs xchg eax, ebx ; exchange 32-bit regs xchg [response], cl ; exchange 8-bit mem op with CL xchg [total], edx ; exchange 32-bit mem op with EDX
Without the XCHG instruction, we need a temporary register to exchange values if using only the MOV instruction.
<<< XCHG Instruction, Exchanging Integers | Index | Memory-to-memory exchange >>> |