Encyclopedia > Xor swap algorithm Assembler Code

  Article Content

Xor swap algorithm/Assembler Code

The following code in x86 assembly language uses the xor swap algorithm to swap 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

However, all x86 microprocessors have an XCHG instruction which does the same work on its operands more efficiently than the above sequence of XORs.



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Shoreham, New York

... the age of 18, 6.2% from 18 to 24, 17.7% from 25 to 44, 36.0% from 45 to 64, and 12.5% who are 65 years of age or older. The median age is 44 years. For every 100 ...

 
 
 
This page was created in 25.7 ms