logoalt Hacker News

snvzztoday at 1:27 PM3 repliesview on HN

Because, unlike RISC-V, x86 has no x0 register.


Replies

crotetoday at 1:55 PM

And the other way around: RISC-V doesn't have a move instruction so that's done as "dst = src + 0", and it doesn't have a nop instruction so that's done as "x0 = x0 + 0". There's like a dozen of them.

It's quite interesting what neat tricks roll out once you've got a guaranteed zero register - it greatly reduces the number of distinct instructions you need for what is basically the same operation.

show 1 reply
jabltoday at 1:40 PM

From your past posting history, I presume that you're implying this makes RISC-V better?

Do we have any data showing that having a dedicated zero register is better than a short and canonical instruction for zeroing an arbitrary register?

show 5 replies
gpderettatoday at 2:52 PM

x86 doesn't need a zero register as it can encode constants in the instruction itself.