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
?
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
?
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.