logoalt Hacker News

DeathArrowtoday at 7:45 AM2 repliesview on HN

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.


Replies

icelusxltoday at 8:19 AM

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.

pjc50today at 8:23 AM

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)