XOR
By Vesper Vei
1 minute read
Table of Contents
XOR(xor)
Basic Function
The XOR instruction performs a bitwise exclusive OR on two operands: dest = dest XOR src。
If the corresponding bits are the same, the result is 0; if they are different, the result is 1.
After execution, EFLAGS is updated.
Instruction Execution Process
- Compute the XOR result
- Write the result back to the destination operand
- Update flags such as ZF, SF, and PF
- CF and OF are cleared to 0
Instruction Format
xor r/m32, r32xor r/m64, r64xor r/m32, imm32xor r/m64, imm32Behavioral Characteristics
- XOR REG, REG → clears the register to zero (a classic fast zeroing method)
- Does not produce a carry
- Commonly used in encryption/obfuscation logic —>rc4 encryption
- Fast and compact in encoding; one of the most common bitwise operations
Common Uses
- Clear a register:
xor eax, eax - Construct specific register values
- Obfuscation algorithms, encoders, and decryptors
- Used in shellcode to avoid badchars