In Programming from the Ground Up one reads that
the XOR operation is faster than the loading operation, so many programmers use it to load a register with a zero. For example, the code
movl $0, %eaxis often replaced by
xorl %eax, %eax
Now, since the book is old, a first question to ask would be whether this observation still applies today.
But in either case, the main question I have is why the two operations have (or had) different performance? What makes (or made) xorl be faster than movl?
I guess a hardware perspective is necessary to understand this?