Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 818 Bytes

mov-eax-ebx.md

File metadata and controls

41 lines (27 loc) · 818 Bytes

mov eax, ebx

Output:

89 d8
^^ ^^
1  2
  1. Opcode
  2. ModR/M

Opcode bits:

1 0 0 0 1 0 0 1
^^^^^^^^^^^ ^ ^
1           2 3
  1. This is a mov.
  2. Move REG to R/M as represented on the ModR/M byte. Otherwise, other way around.
  3. 32-bit operands. Otherwise, 8-bit.

ModR/M bits:

1 1 0 1 1 0 0 0
^^^ ^^^^^ ^^^^^
1   2     3
  1. MOD = 3: REG and R/M are registers.
  2. REG = 3: EBX
  3. REG = 0: EAX

So from the opcode, we move REG (EBX) into R/M (EAX).

Note that two encodings are possible on reg / reg operations: we could swap the before last bit to 1 and both registers.

Both possible encodings are documented on the instruction table:

01 /r    MOV r/m32, r32
03 /r    MOV r32, r/m32

/r says that a MOdR/M follows the opcode, and that the 2 last bits describe it.