zeroing idiom
Setting a register to zero with xor eax, eax instead of mov eax, 0, because it is shorter.
xor eax, eax (2 bytes, versus 5 for mov eax, 0) zeroes rax, and processors recognize it as independent of rax's old value; it also clears CF and OF and sets ZF.
Examples
xor eax, eaxsetseax, and so all ofrax, to 0 in 2 bytes, shorter thanmov eax, 0.
See also