I was trying to decode the following hex numbers:
3b 5c 78 f6
I checked the manual of Intel, and 3b
refers to the opcode of CMP Gv,Ev
.
5c
is 01 011 100
in binary, meaning MOD=01, REG =011, R/M=100.
MOD =01 means this instruction has one-byte displacement. REG=011 means, the instruction compares %ebx
with something. Here is the part I don't understand. When R/M =100 refers to a register, %esp
, if I am correct, how do I use this register in this instruction? The reason why I am confused is that the SIB and displacement (7b f6
)combined together is something like 0x-a(%exa,%edi,2)
in ATT syntax, so I think the instruction should be something like cmp 0x-a(%eax,%edi,2),%ebx
in att syntax.
I am not sure if my decoding process was correct. If the process was correct, what does R/M=100 refer to? What is the purpose of R/M here?