From time to time we have to analyze pieces of assembler code (IA32), and more than often i come across an instruction that looks like this:
xor ax, ax
It's a common assembler idiom to set a register to 0.
xor ax, ax corresponds to ax = ax ^ ax which, as you already notices, is effectively ax = 0.
ax = ax ^ ax
ax = 0
If I recall correctly the main advantage is that its code-size is smaller than mov ax, 0
mov ax, 0