Description
The 8086 microprocessor’s instruction set defines the entire group of commands the CPU can execute, built upon a variable-length machine language format and flexible addressing modes.
3.1 Machine Language Instruction Format 🤖
The 8086 machine language instruction is variable-length, ranging from 1 to 6 bytes. It is composed of several fields that encode the operation and its operands.
| Field Name | Size (Bits) | Description |
| Opcode | 6 bits | Specifies the type of operation (e.g., MOV, ADD, JMP). |
| D (Direction) | 1 bit | Specifies the direction of data transfer: $D=1$ means the REG field is the destination; $D=0$ means the REG field is the source. |
| W (Word/Byte) | 1 bit | Specifies the size of the operand: $W=1$ for a word (16-bit) operation; $W=0$ for a byte (8-bit) operation. |
| MOD (Mode) | 2 bits | Specifies the addressing mode of the operand. It determines if the operand is a register or a memory location, and how the memory address is calculated (e.g., with or without displacement). |
| REG (Register) | 3 bits | Specifies one of the register operands for the instruction (e.g., AX, BX, CX, etc.). |
| R/M (Register/Memory) | 3 bits | Together with the MOD field, it specifies the second operand, which can be another register or a memory addressing mode. |
| Displacement/Data | 1-4 bytes | The final optional field(s) containing the immediate data or the displacement (offset) required to calculate a memory address. |
3.2 Addressing Modes 📍
Addressing modes are the ways in which the 8086 microprocessor calculates the Effective Address (EA) of an operand (data) for an instruction.
| Category | Addressing Mode | Effective Address (EA) / Data Location | Example Instruction |
| Data | Immediate | The operand is part of the instruction itself. | MOV AX, 1234H (1234H is the data) |
| Data | Register | The operand is located in a general-purpose register. | MOV AX, BX (Data is in BX) |
| Memory | Direct | The offset address (displacement) is specified directly in the instruction. | MOV AL, [5000H] (EA = 5000H) |
| Memory | Register Indirect | The EA is held in a pointer/index register (BX, SI, DI). | MOV AL, [BX] (EA = content of BX) |
| Memory | Register Relative (Base/Index + Disp) | EA = Base/Index Register + Displacement (8-bit or 16-bit). | MOV CL, [SI + 04H] (EA = SI + 4H) |
| Memory | Base-Indexed | EA = Base Register (BX/BP) + Index Register (SI/DI). | MOV AX, [BX + SI] (EA = BX + SI) |
| Memory | Relative Based-Indexed | EA = Base Reg + Index Reg + Displacement. | MOV CH, [BP + DI + 20H] (EA = BP + DI + 20H) |
| Implicit/Implied | The operand is implicitly defined by the instruction itself (no explicit operand). | STC (Sets the Carry Flag – CF) |
3.3 Instruction Set Categories and Long Keywords 📜
The 8086 instruction set is broadly classified into the following groups:
1. Data Transfer Instructions ➡️
Used to move data between registers, memory, and I/O ports.
| Keyword | Long Keyword / Function |
| MOV | MOVe data from source to destination. |
| PUSH | PUSH data onto the stack. |
| POP | POP data from the stack. |
| XCHG | EXCHanGe contents of two operands. |
| LEA | Load Effective Address (calculates offset). |
| IN / OUT | Input from / Output to an I/O PORT. |
2. Arithmetic Instructions ➕
Perform mathematical operations on binary or BCD/ASCII data.
| Keyword | Long Keyword / Function |
| ADD / ADC | ADD / Add with Carry. |
| SUB / SBB | SUBtract / Subtract with Borrow. |
| INC / DEC | INCrement / DECrement by 1. |
| MUL / IMUL | Multiply (Unsigned) / Integer MULtiply (Signed). |
| DIV / IDIV | DIVide (Unsigned) / Integer DIVide (Signed). |
| CMP | CoMPare (performs subtraction to set flags, but discards result). |
| AAA, AAM, etc. | ASCII Adjust After… (for decimal arithmetic using ASCII/BCD). |
3. Logical Instructions (Bit Manipulation) 💡
Perform bitwise operations and bit shifts/rotations.
| Keyword | Long Keyword / Function |
| AND / OR / XOR | Bitwise AND / OR / EXclusive-OR. |
| NOT | Bitwise NOT (One’s complement). |
| TEST | Performs bitwise AND operation without storing the result (only affects flags). |
| SHL / SAL | Shift Hemispheres Left / Shift Arithmetic Left. |
| SHR / SAR | Shift Hemispheres Right (Logical) / Shift Arithmetic Right. |
| ROL / ROR | ROtate Left / ROtate Right (bits circle back). |
| RCL / RCR | Rotate Carry Left / Rotate Carry Right (uses the Carry Flag, CF). |
4. Flag Manipulation Instructions 🚩
Directly modify the individual control flags within the 8086 Flag Register.
| Keyword | Long Keyword / Function |
| CLC / STC / CMC | CLear, SeT, or CoMplement Carry Flag (CF). |
| CLD / STD | CLear / SeT Direction Flag (DF – for string operations). |
| CLI / STI | CLear / SeT Interrupt Flag (IF – enables/disables hardware interrupts). |
| LAHF / SAHF | Load AH from Flags / Store AH to Flags (for 8080 compatibility). |
| PUSHF / POPF | PUSH / POP the Flags register onto/from the stack. |
5. String Operation Instructions 🧵
Instructions designed to efficiently process blocks of data (strings) using SI and DI registers. They can often be prefixed with REP (Repeat).
| Keyword | Long Keyword / Function |
| MOVS | MOVe String (byte or word from DS:SI to ES:DI). |
| CMPS | CoMPare String (byte or word). |
| SCAS | SCAn String (compare accumulator AL/AX with string element at ES:DI). |
| LODS | LOaD String (byte or word from DS:SI into AL/AX). |
| STOS | STOre String (byte or word from AL/AX into ES:DI). |
| REP | REPeat Prefix (repeats the subsequent string instruction until CX = 0). |
6. Program Control Transfer (Branching) Instructions ↩️
Alter the sequence of program execution.
| Keyword | Long Keyword / Function |
| JMP | JuMP Unconditional (always jumps to a new location). |
| CALL / RET | CALL a procedure (pushes return address) / RETurn from a procedure. |
| Conditional Jumps | Jump if Zero (JZ), Jump if Not Carry (JNC), etc. (jumps only if a flag condition is met). |
| LOOP / LOOPE / LOOPNE | LOOP (decrements CX, jumps if CX $\ne 0$) / LOOP while Equal / LOOP while Not Equal. |
| INT / IRET | Software INTerrupt / Interrupt RETurn. |
7. Processor Control Instructions ⚙️
Control the overall state and functionality of the microprocessor.
| Keyword | Long Keyword / Function |
| HLT | HaLT (stops processor execution until a reset or interrupt occurs). |
| NOP | No OPeration (CPU does nothing for one clock cycle). |
| WAIT | WAIT (pauses the processor until the TEST pin is activated/low). |
| ESC | ESCape (used for interface with a coprocessor like the 8087). |
| LOCK | LOCK Prefix (causes the bus LOCK signal to be active, preventing other bus masters from accessing memory). |





Reviews
There are no reviews yet.