0

My professor wanted to show us how to decode instructions, as an example he took (at&t syntax):

movq $8, 4(%rdx,%rsi,4)

I'm quit lost on why he chose the opcode to be C7.

From an online table I found:

C7- move imm32 to r/m32 or imm32 (sign extended to 64 bits) to r/m64

How he figured out it's sign extended, plus why we are moving 32 imm? The instruction is so clear it's movq not movl

algo
  • 101
  • 6
  • Please show the full encoding of the instruction. Often you need to decode (up to) several bytes in order to know which variant you have. – 500 - Internal Server Error Oct 05 '21 at 21:22
  • "or imm32 (sign extended to 64 bits) to r/m64" is the key here. This applies if you have a REX prefix byte, which isn't considered part of the opcode. `8` can be encoded as a 32-bit number, but what's actually stored is the 64-bit number obtained by sign extension, so the `q` suffix is appropriate. – Nate Eldredge Oct 05 '21 at 21:32
  • 3
    There is no other option except the sign extending `mov` because there is no `mov r/m64, imm64`. – Jester Oct 05 '21 at 22:15

0 Answers0