Hacker News new | ask | show | jobs
by DeathArrow 61 days ago
30 years ago, when I wanted to 0 a register in assembly I used something like xor ah, ah because it was a bit more performant.
2 comments

It still is. The CPU's register renamer can detect these instructions to not have data dependencies and can zero the register itself. It doesn't send the instruction to the execution engine meaning they use no execution resources and have zero latency.
IIRC that's because that instruction is one byte while a "load immediate" would have to express 0 as one or more bytes.

(See also the wacky way in which ARM "load immediate" works)