title: What is the best way to set a register to zero in x86 assembly: xor, mov or and?
body: <p>All the following instructions do the same thing: set <code>%eax</code> to zero. Which way is optimal (requiring fewest machine cycles)?</p>
  
  <pre><code>xorl   %eax, %eax
  mov    $0, %eax
  andl   $0, %eax
  </code></pre>