XOR'ing a register with itself is the idiom for zeroing it out. Why not sub?
XOR'ing a register with itself is a common assembly idiom for zeroing it out because it's shorter and faster than subtraction. The article explains why this optimization is preferred over using the SUB instruction in x86 architecture.