0% found this document useful (0 votes)
9 views8 pages

8086 Microprocessor All Instruction

The 8086 microprocessor, introduced by Intel in 1978, features a comprehensive set of instructions categorized into data transfer, arithmetic, logic, control transfer, string, flag control, and compare/test instructions. Each category includes specific operations such as MOV, ADD, AND, JMP, and string manipulation commands like MOVSB and CMPSB, which facilitate efficient data handling and processing. This instruction set is crucial for understanding the architecture and functionality of early computing systems.

Uploaded by

gauravpekde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views8 pages

8086 Microprocessor All Instruction

The 8086 microprocessor, introduced by Intel in 1978, features a comprehensive set of instructions categorized into data transfer, arithmetic, logic, control transfer, string, flag control, and compare/test instructions. Each category includes specific operations such as MOV, ADD, AND, JMP, and string manipulation commands like MOVSB and CMPSB, which facilitate efficient data handling and processing. This instruction set is crucial for understanding the architecture and functionality of early computing systems.

Uploaded by

gauravpekde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

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:

1. Data Transfer Instructions

These instructions move data between registers, memory, and I/O ports.

 MOV: Moves data from one location to another.


o Syntax: MOV destination, source
o Example: MOV AX, BX (Copies the contents of the BX register into the AX
register)
 PUSH: Pushes data onto the stack.
o Syntax: PUSH operand
o Example: PUSH AX (Pushes the value of AX onto the stack)
 POP: Pops data from the stack.
o Syntax: POP operand
o Example: POP AX (Pops the top value from the stack into the AX register)
 XCHG: Exchanges data between two operands.
o Syntax: XCHG operand1, operand2
o Example: XCHG AX, BX (Exchanges the values of AX and BX)
 IN: Reads data from an input port.
o Syntax: IN accumulator, port
o Example: IN AL, 60h (Reads a byte of data from port 60h into AL)
 OUT: Sends data to an output port.
o Syntax: OUT port, accumulator
o Example: OUT 60h, AL (Writes the byte in AL to output port 60h)

2. Arithmetic Instructions

These instructions perform basic arithmetic operations like addition, subtraction, multiplication,
and division.

 ADD: Adds two operands.


o Syntax: ADD destination, source
o Example: ADD AX, BX (Adds the contents of BX to AX)
 SUB: Subtracts the source operand from the destination operand.
o Syntax: SUB destination, source
o Example: SUB AX, BX (Subtracts the value of BX from AX)
 MUL: Multiplies the accumulator by the operand.
o Syntax: MUL operand
o Example: MUL BX (Multiplies AX by BX; result is stored in AX and DX)
 DIV: Divides the accumulator by the operand.
o Syntax: DIV operand
o Example: DIV BX (Divides AX by BX; quotient in AL, remainder in AH)
 INC: Increments an operand by 1.
o Syntax: INC operand
o Example: INC AX (Increments the value of AX by 1)
 DEC: Decrements an operand by 1.
o Syntax: DEC operand
o Example: DEC AX (Decrements the value of AX by 1)

3. Logic Instructions

These instructions perform bitwise logical operations like AND, OR, XOR, etc.

 AND: Performs bitwise AND between two operands.


o Syntax: AND destination, source
o Example: AND AX, BX (Performs a bitwise AND between AX and BX)
 OR: Performs bitwise OR between two operands.
o Syntax: OR destination, source
o Example: OR AX, BX (Performs a bitwise OR between AX and BX)
 XOR: Performs bitwise XOR between two operands.
o Syntax: XOR destination, source
o Example: XOR AX, BX (Performs a bitwise XOR between AX and BX)
 NOT: Performs bitwise NOT on the operand (inverts all bits).
o Syntax: NOT operand
o Example: NOT AX (Inverts the bits in AX)
 TEST: Performs bitwise AND between two operands but does not store the result.
o Syntax: TEST operand1, operand2
o Example: TEST AX, BX (Performs AND, setting flags but not storing the result)

4. Control Transfer Instructions

These instructions control the flow of program execution, such as jumps, loops, and subroutine
calls.

 JMP: Unconditional jump to another instruction.


o Syntax: JMP destination
o Example: JMP label (Jumps to the instruction labeled label)
 JE/JZ: Jump if equal (Zero Flag is set).
o Syntax: JE destination or JZ destination
o Example: JE label (Jumps if the Zero Flag is set, meaning the two compared
operands were equal)
 JNE/JNZ: Jump if not equal (Zero Flag is cleared).
o Syntax: JNE destination or JNZ destination
o Example: JNE label (Jumps if the Zero Flag is cleared)
 CALL: Calls a procedure (subroutine).
o Syntax: CALL address
o Example: CALL procedure (Jumps to the procedure procedure)
 RET: Returns from a procedure.
o Syntax: RET
o Example: RET (Returns control to the calling procedure)
 LOOP: Loops a certain number of times based on the CX register.
o Syntax: LOOP destination
o Example: LOOP label (Decrements CX, and jumps to label if CX is not zero)

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)

6. Flag Control Instructions

These instructions manipulate or check the status of the processor flags.

 CLC: Clears the carry flag.


o Syntax: CLC
o Example: CLC (Clears the Carry Flag)
 STC: Sets the carry flag.
o Syntax: STC
o Example: STC (Sets the Carry Flag)
 CLI: Clears the interrupt flag (disables interrupts).
o Syntax: CLI
o Example: CLI (Disables interrupts)
 STI: Sets the interrupt flag (enables interrupts).
o Syntax: STI
o Example: STI (Enables interrupts)
 CMC: Complements (flips) the carry flag.
o Syntax: CMC
o Example: CMC (Flips the Carry Flag)

7. Compare and Test Instructions

These instructions are used to compare values or test specific conditions without affecting the
operands directly.

 CMP: Compares two operands (subtracts without storing the result).


o Syntax: CMP operand1, operand2
o Example: CMP AX, BX (Compares AX with BX)
 TEST: Performs a bitwise AND between two operands and sets the flags.
o Syntax: TEST operand1, operand2
o Example: TEST AX, BX (Performs AND on AX and BX, setting flags)

 String Instructions in the 8086 Microprocessor

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.

Here’s a breakdown of the string instructions:

1. MOVSB / MOVSW (Move String)

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:

 MOVSB — Moves a byte from [DS:SI] to [ES:DI]


 MOVSW — Moves a word from [DS:SI] to [ES:DI]

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).

2. CMPSB / CMPSW (Compare String)

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:

 CMPSB — Compares the byte at [DS:SI] with the byte at [ES:DI]


 CMPSW — Compares the word at [DS:SI] with the word at [ES:DI]

Explanation:

 SI and DI are the source and destination indexes.


 This operation sets the flags based on the result of the comparison (zero flag, carry flag, etc.).
 SI and DI are adjusted after each comparison (depending on the direction flag).

3. SCASB / SCASW (Scan String)


The SCAS instructions are used to compare the accumulator (AL or AX) with a byte or word at the
current location in the destination string.

 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:

 SCASB — Compares the byte in AL with the byte at [ES:DI].


 SCASW — Compares the word in AX with the word at [ES:DI].

Explanation:

 DI points to the current location in the destination string.


 The accumulator register (AL or AX) is compared with the byte or word at the current position in
the string.
 After execution, DI is incremented or decremented based on the direction flag (DF).

4. LODSB / LODSW (Load String)

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:

 LODSB — Loads the byte at [DS:SI] into AL.


 LODSW — Loads the word at [DS:SI] into AX.

Explanation:

 The SI register points to the current position in the source string.


 After execution, SI is incremented or decremented depending on the direction flag.

5. STOSB / STOSW (Store String)


These instructions store data from the accumulator (AL or AX) into the destination string.

 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:

 STOSB — Stores the byte in AL at [ES:DI].


 STOSW — Stores the word in AX at [ES:DI].

Explanation:

 DI points to the current location in the destination string.


 After execution, DI is incremented or decremented based on the direction flag.

6. REP Prefix (Repeat Instructions)

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:

 REP MOVSB — Repeats the MOVSB instruction CX times.


 REP CMPSB — Repeats the CMPSB instruction CX times.

Explanation:

 CX register holds the number of repetitions.


 After each operation, CX is decremented.
 The instruction continues until CX becomes zero, or a condition is met (e.g., CMPSB sets the zero
flag).
 SI and DI are automatically incremented or decremented depending on the direction flag (DF).

Direction Flag (DF)

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.

 Summary of String Instructions


Instruction Description

MOVSB Move byte from source to destination

MOVSW Move word from source to destination

CMPSB Compare byte from source and destination

CMPSW Compare word from source and destination

SCASB Compare byte in AL with destination

SCASW Compare word in AX with destination

LODSB Load byte from source into AL

LODSW Load word from source into AX

STOSB Store byte from AL to destination

STOSW Store word from AX to destination

REP Repeat string instruction CX times

You might also like