Micro U3
Micro U3
8086 MICROPROCESSOR
Dr.V.Sumitra
Pin diagram
Architecture
Internal registers
Interrupts
Addressing modes
Instruction sets
8086 Microprocessor
Addressing Modes
• Every instruction of a program has to operate on a data.
• The different ways in which a source operand is denoted
in an instruction are known as addressing modes.
1. Register Addressing
Group I : Addressing modes for register and
2. Immediate Addressing immediate data
3. Direct Addressing
5. Based Addressing
Group II : Addressing modes for memory data
6. Indexed Addressing
8. String Addressing
8. String Addressing
41
8086 Microprocessor Group I : Addressing modes for register and
immediate data
Addressing Modes
1. Register Addressing
In immediate addressing mode, an 8-bit or 16-bit
2. Immediate Addressing data is specified as part of the instruction
3. Direct Addressing
Example:
4. Register Indirect Addressing
MOV DL, 08H
5. Based Addressing
The 8-bit data (08H) given in the instruction is
6. Indexed Addressing moved to DL
8. String Addressing
MOV AX, 0A9FH
9. Direct I/O port Addressing
The 16-bit data (0A9FH) given in the instruction is
10. Indirect I/O port Addressing
moved to AX register
11. Relative Addressing
(AX) ← 0A9FH
12. Implied Addressing
42
8086 Microprocessor
Adder
43
8086 Microprocessor
• Supported combinations:
BX SI
+ disp
BP DI 45
8086 Microprocessor Group II : Addressing modes for memory
data
Addressing Modes
1. Register Addressing
2. Immediate Addressing
Here, the effective address of the memory
3. Direct Addressing
location at which the data operand is stored is
4. Register Indirect Addressing given in the instruction.
12. Implied Addressing This addressing mode is called direct because the
displacement of the operand from the segment
base is specified directly in the instruction.
46
8086 Microprocessor Group II : Addressing modes for memory
data
Addressing Modes
1. Register Addressing In Register indirect addressing, name of the
register which holds the effective address (EA)
2. Immediate Addressing will be specified in the instruction.
(CL) ← (MA)
(CH) ← (MA +1)
47
8086 Microprocessor Group II : Addressing modes for memory
data
Addressing Modes
1. Register Addressing In Based Addressing, BX or BP is used to hold the
base value for effective address and a signed 8-bit
2. Immediate Addressing or unsigned 16-bit displacement will be specified
in the instruction.
3. Direct Addressing
In case of 8-bit displacement, it is sign extended
4. Register Indirect Addressing to 16-bit before adding to the base value.
(AL) ← (MA)
48
(AH) ← (MA + 1)
8086 Microprocessor Group II : Addressing modes for memory
data
Addressing Modes SI or DI register is used to hold an index value for
1. Register Addressing
memory data and a signed 8-bit or unsigned
2. Immediate Addressing 16-bit displacement will be specified in the
instruction.
3. Direct Addressing
Displacement is added to the index value in SI or
4. Register Indirect Addressing DI register to obtain the EA.
(CL) ← (MA)
(CH) ← (MA + 1)
49
8086 Microprocessor Group II : Addressing modes for memory
data
Addressing Modes
1. Register Addressing In Based Index Addressing, the effective address
is computed from the sum of a base register (BX
2. Immediate Addressing or BP), an index register (SI or DI) and a
displacement.
3. Direct Addressing
Example:
4. Register Indirect Addressing
MOV DX, [BX + SI + 0AH]
5. Based Addressing
Operations:
6. Indexed Addressing
000AH ← 0AH (Sign extended)
7. Based Index Addressing
50
8086 Microprocessor Group II : Addressing modes for memory
data
Addressing Modes
1. Register Addressing Employed in string operations to operate on string
data.
2. Immediate Addressing
The effective address (EA) of source data is stored
3. Direct Addressing in SI register and the EA of destination is stored in
DI register.
4. Register Indirect Addressing
Segment register for calculating base address of
5. Based Addressing source data is DS and that of the destination data
is ES
6. Indexed Addressing
Addressing Modes
1. Register Addressing These addressing modes are used to access data
from standard I/O mapped devices or ports.
2. Immediate Addressing
In direct port addressing mode, an 8-bit port
3. Direct Addressing address is directly specified in the instruction.
Addressing Modes
1. Register Addressing
2. Immediate Addressing
Addressing Modes
1. Register Addressing
2. Immediate Addressing
3. Direct Addressing
5. Based Addressing
6. Indexed Addressing
Instructions using this mode have no operands.
The instruction itself will specify the data to be
7. Based Index Addressing
operated by the instruction.
8. String Addressing
Example: CLC
9. Direct I/O port Addressing
This clears the carry flag to zero.
10. Indirect I/O port Addressing
54
INSTRUCTION SET
8086 Microprocessor
Instruction Set
8086 supports 6 types of instructions.
2. Arithmetic Instructions
3. Logical Instructions
56
8086 Microprocessor
Generally involve two operands: Source operand and Destination operand of the
same size.
A 8-bit data can only be moved to 8-bit register/ memory and a 16-bit data can be
moved to 16-bit register/ memory.
57
8086 Microprocessor
58
8086 Microprocessor
IN AL, [DX] PORT addr = (DX) OUT [DX], AL PORT addr = (DX)
(AL) ← (PORT) (PORT) ← (AL)
IN AX, [DX] PORT addr = (DX) OUT [DX], AX PORT addr = (DX)
(AX) ← (PORT) (PORT) ← (AX)
60
8086 Microprocessor
ADD A, data
61
8086 Microprocessor
ADDC A, data
62
8086 Microprocessor
SUB A, data
63
8086 Microprocessor
SBB A, data
64
8086 Microprocessor
65
8086 Microprocessor
66
8086 Microprocessor
67
8086 Microprocessor
68
8086 Microprocessor
69
8086 Microprocessor
70
8086 Microprocessor
CMP A, data
71
8086 Microprocessor
72
8086 Microprocessor
73
8086 Microprocessor
74
8086 Microprocessor
75
8086 Microprocessor
76
8086 Microprocessor
77
8086 Microprocessor
78
8086 Microprocessor
79
8086 Microprocessor
Instruction Set
4. String Manipulation Instructions
❑ 8086 instruction set includes instruction for string movement, comparison, scan, load and store.
❑ Offset or effective address of the source operand is stored in SI register and that of the destination
operand is stored in DI register.
80
8086 Microprocessor
Instruction Set
4. String Manipulation Instructions
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
REP
REPNZ/ REPNE
While CX ≠ 0 and ZF = 0, repeat execution of string instruction
(Repeat CMPS or SCAS until ZF = 1) and
(CX) ← (CX) - 1
81
8086 Microprocessor
Instruction Set
4. String Manipulation Instructions
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
MOVS
(MA E) ← (MA)
(MA E ; MA E + 1) ← (MA; MA + 1)
82
8086 Microprocessor
Instruction Set
4. String Manipulation Instructions
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
83
8086 Microprocessor
Instruction Set
4. String Manipulation Instructions
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
Scan (compare) a string byte or word with
accumulator
SCAS
Instruction Set
4. String Manipulation Instructions
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
LODS
85
8086 Microprocessor
Instruction Set
4. String Manipulation Instructions
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
STOS
86
8086 Microprocessor
Instruction Set
5. Processor Control Instructions
Mnemonics Explanation
STC Set CF ← 1
CLC Clear CF ← 0
NOP No operation
ESC opcode mem/ reg Used to pass instruction to a coprocessor which shares the
address and data bus with the 8086
❑ 8086 Unconditional
transfers
Mnemonics Explanation
CALL reg/ mem/ disp16 Call subroutine
88
8086 Microprocessor
• Checks flags
89
8086 Microprocessor
90
8086 Microprocessor
Mnemonics Explanation
JC disp8 Jump if CF = 1
JP disp8 Jump if PF = 1
JO disp8 Jump if OF = 1
JS disp8 Jump if SF = 1
91
Data Transfer Instructions
• LEA: Load Effective Address
• The general format of LEA instruction is
• LEA register, source
• This instruction determines the offset address of the variable or memory location
named as the source and puts this offset address in the indicated 16 bit register.
• Examples:
• LEA BX, COST; Load BX with offset address of COST in data segment where
• COST is the name assigned to a memory location in data segment.
• LEA CX, [BX][SI]; Load CX with the value equal to (BX)+(SI) where (BX) and
• (SI) represents content of BX and SI respectively.
92
Data Transfer Instructions
• LDS: Load register and DS with words from memory
• The general form of this instruction is
• LDS register, memory address of first word
• The LDS instruction copies a word from the memory location specified in the
instruction into the register and then copies a word from the next memory location
into the DS register.
• LDS is useful for initializing SI and DS registers at the start of a string before using
one of the String instructions.
• Example:
• LDS SI,[2000H]; Copy content of memory at offset address 2000H in data segment
to lower byte of SI, content of 2001H to higher byte of SI. Copy content at offset
address 2002H in data segment to lower byte of DS and 2003H to higher byte of
DS.
93
Data Transfer Instructions
• LES, LSS: LES and LSS instructions are similar to LDS
instruction except that instead of DS register, ES and SS
registers are loaded respectively along with the register
specified in the instruction.
• LAHF: This instruction copies the low byte of flag
register into AH.
• SAHF: Store content of AH in the low byte of flag
register.
• Except SAHF and POPF instructions, all other data
transfer instructions do not affect flag register.
94
Arithmetic Instructions
•DAA: Decimal Adjust AL after BCD addition
•This instruction is used to get the result of adding two packed BCD numbers (two
decimal digits are represented in 8 bits) to be a BCD number. The result of addition
must be in AL for DAA to work correctly. If the lower nibble (4 bits) in AL is greater
than 9 after addition or AF flag is set by the addition then the DAA will add 6 to the
lower nibble in AL. If the result in the upper nibble of AL is now greater than 9 or if
the carry flag is set by the addition, then the DAA will add 60H to AL.
•Examples:
•Let AL=0101 1000=58 BCD
• CL=0011 0101=35 BCD
•Consider the execution of the following instructions:
•ADD AL, CL; AL=10001101=8DH and AF=0 after execution
•DAA - Add 0110 (decimal 6) to AL since lower nibble in AL is greater than 9
• AL=10010011= 93 BCD and CF=0
•Therefore the result of addition is 93 BCD.
95
Arithmetic Instructions
•DAS: Decimal Adjust after BCD subtraction
•DAS is used to get the result is in correct packed BCD form after subtracting two
packed BCD numbers. The result of the subtraction must be in AL for DAS to work
correctly. If the lower nibble in AL after a subtraction is greater than 9 or the AF was
set by subtraction then the DAS will subtract 6 from the lower nibble of AL. If the
result in the upper nibble is now greater than 9 or if the carry flag was set, the DAS
will subtract 60H from AL.
•Examples:
•Let AL=86 BCD=1000 0110
•CH=57 BCD=0101 0111
•Consider the execution of the following instructions:
•SUB AL, CH; AL=0010 1111=2FH and CF=0 after execution
•DAS; Lower nibble of result is 1111, so DAS subtracts 06H from AL to make
•AL=0010 1001=29 BCD and CF=0 to indicate there is no borrow.
•The result is 29 BCD.
96
AAA: ASCII AFTER ADDITION
Stack Structure
103
Stack Structure
• Application of Stack: Stack provides a powerful data structure
which has applications in many situations. The main
advantage of the stack is that, We can store data (PUSH) in it
with out destroying previously stored data.
• This is not true in the case of other registers and memory
locations. stack operations are also very fast The stack may
also be used for storing local variables of subroutine and for
the transfer of parameter addresses to a subroutine.
• This facilitates the implementation of re-entrant subroutines
which is a very important software property. The
disadvantage is, as the stack has no fixed address, it is
difficult to debug and document a program that uses stack.
104
Stack Operation
• Stack operation: Operations on stack are performed using
the two instructions namely PUSH and POP. The
contents of the stack are moved to certain memory
locations after PUSH instruction.
• Similarly, the contents of the memory are transferred
back to registers by POP instruction.
105
The PUSH operation of the Stack
• Let us consider two registers (register pair) B & C whose
contents are 25 & 62.
109
Types of Interrupt
An 8086 interrupt can come from any one of the three
sources
• One source is an external signal applied to the Non
Maskable Interrupt (NMI) input pin or to the Interrupt
(INTR) input pin
• An interrupt caused by a signal applied to one of these
inputs is referred to as a hardware interrupt
A second source of an interrupt is execution of
the Interrupt instruction, INT, This is referred to as
Software Interrupt
The third source of an interrupt is some error condition
produced in the 8086 by the execution of an instruction
An example of this is the divide
110
by zero error
Types of Interrupt
Picture
111 Courtesy :Google
Types of Interrupt
114
Software Interrupts
• The first five interrupt vectors are
identical in all Intel processors
• Intel reserves the first 32 interrupt
vectors
• The last 224 vectors are user
available
• Each is four bytes long in real mode
and contains the starting address of
the interrupt service procedure.
• The first two bytes contain the offset
address The last two contain the
segment address