IA-32 Assembly Language Reference Manual

Logical Exclusive OR (xor)

xor{bwl} 	reg[8|16|32], r/m[8|16|32]
xor{bwl} 	r/m[8|16|32], reg[8|16|32]
xor{bwl} 	imm[8|16|32], r/m[8|16|32]
Operation

reg[8|16|32] XOR r/m[8|16|32] -> r/m[8|16|32]

r/m[8|16|32] XOR reg[8|16|32] -> reg[8|16|32]

imm[8|16|32] XOR r/m[8|16|32] -> r/m[8|16|32]

Description

Performs an exclusive OR of each bit in the values specified by the two operands and stores the result in the second operand.

Table 2-4 Exclusive XOR

Values 

Result 

0 XOR 0 

0 XOR 1 

1 XOR 0 

1 XOR 1 

Example

Perform a 8-bit exclusive OR of the constant, 0xff, and the AL register:

xorb $0xff, %al

Perform a 16-bit exclusive OR of the constant, 0xff83, and the contents of the effective address (addressed by the EDI register plus an offset of 4):

xorw $0xff83, 4(%edi)

Perform a 32-bit exclusive OR of the EDX register and the contents of the effective address (addressed by the EDI register plus an offset of 4):

xorl %edx, 4(%edi)