Let's take the following assembly instruction:
add %cl,%bl
This gets encoded as: 00
cb
, or 00000000
11001011
in binary. Putting the cb
into the ModR/M bitfields, it looks like:
1 1 0 0 1 0 1 1
+---+---+---+---+---+---+---+---+
| mod | reg | r/m |
+---+---+---+---+---+---+---+---+
And, inn looking up the register field here we get:
- mod:
11
(Register addressing mode) - reg:
001
(cl register) - r/m:
011
(bl register)
And, I believe 000000ds
is the add
instruction, and d=s=0
since they're all registers. Is that a correct inderstanding of how this instruction is encoded? Additionally, for the 'full encoding' scheme, would the following be accurate (in bytes not bits):
[empty] 0x0 0b11001011 [empty] [empty] [empty]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Prefix Instruction Mod-reg-r/m Scale displacement immediate
Are there any things I'm missing here in my attempt at 'decoding' the instruction?