Slide 11.6: OR instruction Slide 11.8: NOT instruction Home |
XOR
Instruction
The XOR 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.
|
|
XOR — Exclusive OR |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
XOR
reverses itself when applied twice to the same operand. This makes it an ideal tool for a simple form of data encryption.
XOR ed with 0 |
XOR ed with 1 |
XOR ed Twice |
.code mov eax, 12345678h xor eax, 00000000h call WriteHex |
.code mov eax, 12345678h xor eax, 0FFFFFFFFh call WriteHex |
.code mov eax, 0 mov al, 00111010b mov ch, 10100011b xor al, ch xor al, ch call WriteHex |
Output | Output | Output |