I'm testing the following code:
.intel_syntax noprefix
.data
.Ltest_data:
.byte 0xEF, 0xBE, 0xAD, 0xDE, 0xBE, 0xBA, 0xED, 0xFE
.text
...
movzx rax, BYTE PTR[.Ltest_data] # 0xEF
movzx rax, WORD PTR[.Ltest_data] # 0xBEEF
movsx rax, DWORD PTR[.Ltest_data] # 0xFFFFDEADBEEF (sign-extension)
mov rax, QWORD PTR[.Ltest_data] # 0xFEEDBABEDEADBEEF
# These don't work:
# mov rax, DWORD PTR[.Ltest_data]
# movzx rax, DWORD PTR[.Ltest_data]
...
Looking at the Intel manual, it seems like there's no way to use mov
/movzx
to move a dword to a qword; the only way I see is to use movsx
and mask out the top 32 bits. This is surprising, giving the insane amount of instructions available for x86_64.
Is this correct, or am I missing something?