Why x86 Zeroes a Register With `xor eax, eax`

Why x86 Zeroes a Register With xor eax, eax If you have ever disassembled a program - even a trivial one - you have almost certainly seen this line: xor eax , eax It looks like a riddle. The instruction says "XOR the eax register with itself," but what it actually means is "set eax to zero." In optimized code, compilers and assembly programmers commonly reach for it instead of the more obvious: mov eax , 0 Both leave eax holding zero. So why does the industry so often prefer the cryptic one? The short answe

添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论