What is the best way to set a register to zero in x86 assembly: xor, mov or and?
Asked 07 September, 2021
Viewed 1K times
  • 53
Votes

All the following instructions do the same thing: set %eax to zero. Which way is optimal (requiring fewest machine cycles)?

xorl   %eax, %eax
mov    $0, %eax
andl   $0, %eax

1 Answer