3 ms·
To be fair, the choice of xor eax, eax is 'faster' than mov eax, 0. The xor option is only two bytes versus the five of mov, which can have I$ and decode width
by monocasa 5y ago
To be fair, the choice of xor eax, eax is 'faster' than mov eax, 0. The xor option is only two bytes versus the five of mov, which can have I$ and decode width concerns. And back in the day, five bytes was pretty awkward for up to 32 bit data buses, where you'd need at least two cycles to even read the mov instruction. That's why existing code tended to use xor eax, eax in the first place, even before Intel started adding rename hardware to their processors.
- bonzini 5y agoSame for xor ax,ax on 16-bit processors by the way (2 bytes vs 3), and even earlier for the 8-bit 8080 (1 byte vs 2). The xor or sub trick dates to the late 70s.