I'm debugging the following function:
_print_func:
mov rdx, 0xFFFFFFFFFFFFFFFF
mov rax, 0x01
mov rdi, 0x01
mov rsi, str
movzx dx, byte [str_len] ; <--- Here
syscall
ret
The function was compiled with
nasm -g -f elf64 2.asm
The issue I faced with is that after stepping the line movzx dx, byte [str_len] the rdx content was:
rdx 0xffffffffffff000d -65523
And it was reasonable. Now, replacing the instruction as this:
_print_func:
mov rdx, 0xFFFFFFFFFFFFFFFF
mov rax, 0x01
mov rdi, 0x01
mov rsi, str
movzx edx, byte [str_len] ; dx replaced with edx
syscall
ret
Now the register content is this:
rdx 0xd 13
It looks like moving to 32-bit register zero extending it's 64 bit high part. Why is that happening?
Why did not we zero extend eax when movzx dx, byte [str_len]?