#1
XOR'ing a register with itself is the idiom for zeroing it out. Why not sub?
XOR reg, reg zeroes a register faster than SUB reg, reg by 1 CPU cycle on most x86 architectures, a micro-optimization that still ignites debate among assembly die-hards. With 38 points and 20 comments, this thread exemplifies the arcane processor knowledge that keeps low-level programming alive.
Photos (1)

Comments on "XOR'ing a register with itself is the idiom for zeroing it out. Why not sub?"
Have a take on this ranking?
Comments are how the argument actually happens here. Posting one needs a free account — it takes about a minute.
No comments yet.
The first comment sets the terms of the argument.