8086 Microprocessor All Instruction
8086 Microprocessor All Instruction
The 8086 microprocessor, developed by Intel in 1978, is one of the early 16-bit processors and
is considered a precursor to modern computer processors. It has a rich set of instructions and
features that make it important in the evolution of computing.
Here’s an explanation and description of the different types of instructions in the 8086
microprocessor, categorized based on their functionality:
These instructions move data between registers, memory, and I/O ports.
2. Arithmetic Instructions
These instructions perform basic arithmetic operations like addition, subtraction, multiplication,
and division.
3. Logic Instructions
These instructions perform bitwise logical operations like AND, OR, XOR, etc.
These instructions control the flow of program execution, such as jumps, loops, and subroutine
calls.
5. String Instructions
These instructions are used to manipulate strings, especially useful for moving or comparing
blocks of data.
MOVSB: Moves a byte from the string source to the string destination.
o Syntax: MOVSB
o Example: MOVSB (Moves byte from DS:SI to ES:DI)
MOVSW: Moves a word (2 bytes) from the string source to the string destination.
o Syntax: MOVSW
o Example: MOVSW (Moves word from DS:SI to ES:DI)
CMPSB: Compares a byte from the source string with the byte in the destination string.
o Syntax: CMPSB
o Example: CMPSB (Compares byte at DS:SI with byte at ES:DI)
SCASB: Scans a byte in the accumulator and compares it with the byte at ES:DI.
o Syntax: SCASB
o Example: SCASB (Compares AL with byte at ES:DI)
REP: Repeats a string instruction multiple times.
o Syntax: REP instruction
o Example: REP MOVSB (Repeats MOVSB until CX is zero)
These instructions are used to compare values or test specific conditions without affecting the
operands directly.
In the 8086 microprocessor, string instructions are a set of commands designed to handle operations
involving strings, which are contiguous blocks of memory. These instructions are essential when working
with arrays or larger blocks of data because they allow you to efficiently process multiple bytes or words
in a single instruction.
The 8086 provides a set of specialized string instructions for moving, comparing, and processing strings
of data. These instructions can operate on bytes (8 bits) or words (16 bits) and are typically used with
the SI (Source Index) and DI (Destination Index) registers to point to the source and destination of the
data.
These instructions are used to move data from the source string to the destination string.
MOVSB: Move a byte from the source string to the destination string.
MOVSW: Move a word (2 bytes) from the source string to the destination string.
Syntax:
MOVSB / MOVSW
Example:
Explanation:
The SI register points to the source string (using the DS segment by default).
The DI register points to the destination string (using the ES segment by default).
After execution:
o SI and DI are incremented (or decremented, depending on the direction flag, DF).
These instructions compare the source string to the destination string without storing the result of the
comparison. The result is stored in the flags (Zero Flag, Carry Flag, etc.).
CMPSB: Compare a byte from the source string with a byte from the destination string.
CMPSW: Compare a word (2 bytes) from the source string with a word from the destination
string.
Syntax:
CMPSB / CMPSW
Example:
Explanation:
SCASB: Scan a byte in the accumulator and compare it with the byte in the destination string.
SCASW: Scan a word (2 bytes) in the accumulator and compare it with the word in the
destination string.
Syntax:
SCASB / SCASW
Example:
Explanation:
These instructions load data from the source string into the accumulator (AL or AX).
LODSB: Load a byte from the source string into the accumulator (AL).
LODSW: Load a word (2 bytes) from the source string into the accumulator (AX).
Syntax:
LODSB / LODSW
Example:
Explanation:
STOSB: Store the byte in the accumulator (AL) to the destination string.
STOSW: Store the word (2 bytes) in the accumulator (AX) to the destination string.
Syntax:
STOSB / STOSW
Example:
Explanation:
The REP prefix is used to repeat a string instruction (like MOVSB, CMPSB, SCASB, etc.) a specific number
of times. The number of repetitions is determined by the CX register.
Syntax:
REP instruction
Example:
Explanation:
The Direction Flag (DF) determines the direction in which the SI and DI registers will increment or
decrement during string operations:
DF = 0 (default): SI and DI are incremented.
DF = 1: SI and DI are decremented.
The DF can be changed using the CLI (Clear Interrupt Flag) and STI (Set Interrupt Flag) instructions.