logoalt Hacker News

flohofwoetoday at 8:00 AM4 repliesview on HN

That comment is not very useful without pointing to realworld CPUs where SUB is more expensive than XOR ;)

E.g. on Z80 and 6502 both have the same cycle count.


Replies

HarHarVeryFunnytoday at 12:01 PM

The 6502 doesn't support XOR A or SUB A, and in fact doesn't have a SUB opcode at all, only SBC (subtract with carry, requiring an extra opcode to set the carry flag beforehand).

show 1 reply
brigadetoday at 8:06 AM

Cortex A8 vsub reads the second source register a cycle earlier than veor, so that can add one cycle latency

Not scalar, but still sub vs xor. Though you’d use vmov immediate for zeroing anyway.

GoblinSlayertoday at 9:24 AM

Harvard Mark I? Not sure why people think programming started with Z80.

show 2 replies