Question regarding converting assembly to c -- specifically what the movzbl instruction does?

495 views Asked by At

I am trying to figure out what this in assembly would mean in C:

movq 16(%rdi), %rdx
movq 16(%rsi), %rax
movzbl (%rdx), %edx

I am mostly confused about what the movzbl (%rdx), %edx will do. Thanks!

1

There are 1 answers

1
Nate Eldredge On

This is AT&T syntax for the movzx instruction. It fetches one byte from the address contained in %rdx, zero-extends it to 32 bits, and stores the result in %edx.

As with every x86-64 instruction that writes to a 32-bit register, the high half of the corresponding 64-bit register %rdx is also zeroed. So you may also think of this instruction as zero-extending an 8-bit value to 64 bits.