Write the use of XCHG operation with example.

Subject Microprocessor and Assembly Language
NU Year Set: 6.(c) Marks: 2 Year: 2010
  • The XCHG (exchange data) instruction exchanges the contents of two operands.

  • There are three variants:

        XCHG reg, reg
        XCHG reg, mem
        XCHG mem, reg
    
  • You can exchange data between registers or between registers and memory, but not from memory to memory:

            xchg    ax, bx       ; Put AX in BX and BX in AX
            xchg    memory, ax   ; Put "memory" in AX and AX in "memory"
            xchg    mem1, mem2   ; Illegal, can't exchange memory locations!
    
  • The rules for operands in the XCHG instruction are the same as those for the MOV instruction...

Login to post your comment.