I used a website to encode this:
movw $8, 4(%r8d,%esi,4)
and got:
encoding (hex): 67 66 41 C7 44 B0 04 08 00
Thanks to you I nearly understand everything except 2 small points:
Why there is no match?
There is a match. It's the first one "mov imm16 to r/m16", because of the w
in the mnemonic movw
. r/m16
means that 16 bits (two bytes) of memory are being read/written. It so happens that you are using a 32-bit effective address to identify which two bytes of memory are to be written, but that's not part of the r/m16
notation.
The immediate is two bytes because two bytes are to be written. There would be no point in having more. Though there are some examples, like the third case, where the immediate is shorter than the operand size and is zero- or sign-extended.