I have following code:

sub rsp, 40                 ; 00000028H
lea rcx, OFFSET FLAT:$SG4237
call    printf
xor eax, eax
add rsp, 40                 ; 00000028H
ret 0

Why there is xor eax, eax , instead of xor rax, rax?


1 Answer 1


In x64, any operation on a 32-bit register clears the top 32 bits of the corresponding 64-bit register too, so there's no need to use xor rax, rax which would necessitate an extra REX byte for encoding.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.