3

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?

7

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, privacy policy and cookie policy

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