XOR Instruction


The instruction performs a boolean (bitwise) exclusive-OR operation between each pair of matching bits in two operands and places the result in the destination operand. The operands can be 8, 16, or 32 bits, and they must be the same size.
X Y X XOR Y
0 0 0
0 1 1
1 0 1
1 1 0

XOR — Exclusive OR


Usage: XOR dest, src

Flag O D I S Z A P C
Result *     * * ? * 0

Performs a bitwise exclusive OR of the operands and returns the result in the destination.
Clocks
Operands 286 386 486 Size Bytes
reg, reg 2 2 1 2
mem, reg 7 6 3 2-4
reg, mem 7 7 2 2-4
reg, immed 3 2 1 3-4
mem, immed 7 7 3 3-6
accum, immed 3 2 1 2-3

XORed with 0 XORed with 1 XORed Twice
 INCLUDE Irvine32.inc
 .data
  dummy  WORD  ?
 .code
 main PROC
  mov   eax, 12345678h
  xor   eax, 00000000h
  call  WriteHex
  exit
 main ENDP
 END main

 INCLUDE Irvine32.inc
 .data
  dummy  WORD  ?
 .code
 main PROC
  mov   eax,  12345678h
  xor   eax, 0FFFFFFFFh
  call  WriteHex
  exit
 main ENDP
 END main

 INCLUDE Irvine32.inc
 .data
  dummy  WORD  ?
 .code
 main PROC
  mov   eax, 0
  mov   al, 00111010b
  mov   ch, 10100011b
  xor   al, ch
  xor   al, ch
  call  WriteHex
  exit
 main ENDP
 END main

Output Output Output

 

 

 

 

 

 






      “I was in my car driving back from work.    
      A police officer pulled me over and knocked on my window.    
      I said, ‘One minute I’m on the phone.’”    
      ― Alan Carr