x86 assembly - mov and movzx from dword to qword?

1.6k views Asked by At

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?

0

There are 0 answers