If you've done x86 programming, you probably know the ModR/M byte. This byte follows the instruction opcode and describes the memory access mode. Based on octal, this byte's mod, reg, and r/m fields specify the mode, register to use, and a register or memory mode.
First, the 8086 uses the "Group Decode ROM" to analyze the instruction. It determines if it uses a ModR/M byte, a word bit, ALU, and various other features. The mod and r/m fields are copied into the N and M registers, internal 8086 registers that are invisible to the programmer.