8086 - Microprocessor and Applications (AU-CBE, R2008)
8086 - Microprocessor and Applications (AU-CBE, R2008)
8086 - Microprocessor and Applications (AU-CBE, R2008)
Intel 8086:
Features:
1. 16-bit Data bus
2. Computes 16 bit / 32 bit data.
3. 20-bit address bus.
4. More memory addressing capability (220 = 1MB)
5. 16 bit Flag register with 9 Flags
6. Can be operated in Minimum mode and Maximum mode
7. Has two stage pipelined architecture
8. No internal clock generation
9. 40 pin DIP IC - HMOS technology
10. Operates on +5V supply voltage
11. Has more powerful instruction set
When MN/MX (low) pin is in logic 1, the 8086 microprocessor operates in minimum mode
system. In this mode, the microprocessor chip itself gives out all the control signals.
2 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
3 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
8086 – ARCHITECTURE:
The 8086 processor is divided into two independent functional units. They are,
• The bus interface unit (BIU).
• The Execution Unit (EU).
These two units are linked using an internal data bus.
4 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
It contains the following blocks to provide functions such as fetching & queuing of
instructions and bus control.
1. Segment registers
2. Instruction pointer
3. Instruction queue
4. Address generation
5. Bus control circuit
1. Segment Registers:
8086 processor has capability to address memory of size 1 MB and the memory is divided
into 16 segments of up to 64 Kbytes each. Each 64KB segment can be used to store the
code, data, stack, etc., separately and the segment address of the same is stored in
corresponding segment registers.
2. Instruction Queue:
The BIU’s instruction queue is a First In First Out (FIFO) group of registers in which up to
six bytes of instruction code are projected from memory.
This is done to speed up program execution by overlapping instruction fetch with
execution. This mechanism is referred to as pipe lining.
• If queue is full, the BIU does not perform any bus cycle i.e., BIU does not prefetch any
instructions. Therefore, BIU may prefetch the instructions from memory until queue is
full.
• While fetching the instruction from memory, if the Execution Unit (EU) interrupts the
BIU for memory access, the BIU first complete fetching and then services the EU.
• If a subroutine call or Jump instructions are encountered, the BIU will reset the queue
and begin refilling after passing the new instruction to the EU.
3. Address Generation:
BIU contains an adder, which is used to produce the 20-bit physical address of memory by
addressing the contents of segment address and offset address.
Execution Unit:
The Execution unit (EU) takes instruction from instruction queue, decodes and executes
instructions one after another.
It contains the following blocks to provide functions such as decoding and execution of
instructions.
1. 16-bit ALU
2. 8x16-bit Registers (AX, BX, CX, DX, SP, BP, SI & DI).
3. 16-bit Flag Register
1. ALU
The ALU has the capacity to handle 16-bit data and it performs several arithmetic and
logical operations on 16-bit / 32-bit data.
6 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
2. General Registers
There are eight 16-bit general registers in EU of 8086 to store 16 bit/8 bit data. They are
AX, BX, CX, DX, SP, BP, SI & DI
The four 16-bit registers, AX, BX, CX and DX are combination of two 8-bit registers ie.,
H-higher byte and L-lower byte. These registers can be used to store a 16-bit data when
used as a whole 16-bit register or store 8-bit data when used separately.
BX - the only general-purpose 16-bit register & also used for addressing memory.
CX register is the 16-bit counter register used along with LOOP instructions.
DX is the data register is used to hold excess 16-bit result while performing multiplication,
division, etc.
SP & BP are point registers, which are used to access data in stack segment and other
segments.
3. Flag Register:
The EU also contains a 16-bit flag register which holds the status flags typically after an
ALU operation. The flag register of 8086 micro processor is,
O – Overflow flag
D – Direction flag
I – Interrupt flag
S – Sign flag
Z – Zero flag
AC– Auxiliary carry flag
P – Parity flag
CY– Carry flag
7 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
These flags reflect the result of Operations Performed by ALU. They are,
Over flow flag (O): This flag is set, if an overflow occurs during the arithmetic
operation of two signed numbers.
Sign flag (S): This flag is set, if an MSB of the accumulator is set after any
computation.
Zero flag (Z): This flag is set, if the result of any computation is zero.
Auxiliary carry flag (AC): This flag is set, if there is a carry from the third bit, during
addition or borrow.
Parity flag (P): The flag is set, if the lower byte result contains even number of 1’s.
Carry flag (CY): This flag is set, if any computation result contains a carry.
Direction Flag: This flag is set, if the string is processed from higher address towards
lower address. Otherwise, the flag is reset. This is used only in string manipulation
instructions.
Interrupt flag: This flag is set, only when maskable interrupts are recognized.
Trap flag: When a trap interrupt is received by the processor, this flag is set, which
indicates, the processor to execute the current instruction and to transfer the control to
trap service routine. In Other words, When 8086 enters in single step mode, this flag is
set.
8 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
ADDRESSING MODES:
9 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
10 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
11 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
PUSH
• It decrements the stack pointer by 2.
• It stores the 16 bit data from the source to the address in the stack pointer.
Eg. : SP = 80983H
CX = 49A3H
PUSH CX
[CX] SP
SP = 80981H
POP
• It stores the 16 bit data from the destination to the stack pointer.
• It increments the stack pointer by 2.
Eg. : SP = 80983H
CX = 49A3H
POP CX
[CX] SP
SP = 80985H
12 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
LEA:
• Load effective address.
• The mnemonics is LEA register, source.
• Source is having the offset of the memory location and this instruction load this
address into 16 bit register.
LDS:
• The mnemonics is LDS register, memory address of first word.
• It copies a word from two memory locations into the register.
• It then copies a word from next two memory locations into the DS register.
Eg. : LDS CX, [391AH]
LES:
• The mnemonics is LES register, memory address of first word.
• It copies a word from two memory locations into the register.
• It then copies a word from next two memory locations into the ES register.
Eg. : LES CX, [391AH]
LAHF:
This instruction copies the contents of lower byte of 8086 flag register to AH register.
SAHF:
The contents of the AH register are copied into the lower byte of the 8086 flag register.
PUSHF:
This instruction decrements the stack pointer by 2 and copies the word in the flag
register to the memory locations pointed by the stack pointer.
POPF: This instruction copies a word the two memory locations at the top of the stack
to the flag register and increments the stack pointer by 2.
IN:
• This instruction will copy data from a port to the accumulator.
• If an 8 bit port is read the data will go to AL and if an 16 bit port is read the data
will go to AX.
13 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
OUT:
• This instruction will copy data from a port to the accumulator.
• The OUT instruction copies a byte from AL or a word from AX to the specified port.
A. Addition Instructions:
B. Subtraction Instructions:
C. Multiplication Instruction:
MUL:
• It is used to multiply an unsigned byte from the source and unsigned byte in AL
register and stores the result in AX.
• It is used to multiply an unsigned word from the source and unsigned word in
AX register and stores the high word of result stored in DX and low word in
AX.
Eg. : MUL BL - AL x BL, result stored in AX.
MUL BX – AX x BX, High word of result stored in DX and low word in AX.
D. Division Instruction:
DIV - It is used to divide an unsigned word (16 bit) by a byte (8 bit) or to divide an
unsigned double word (32 bit) by a word (16 bit).
Eg. : DIV CL
Word in AX / Byte in CL, Quotient stored in AL and remainder in AH.
IDIV - It is used to divide a signed word (16 bit) by a byte (8 bit) or to divide a signed
double word (32 bit) by a word (16 bit).
CWD - It copies the D15 bit of AX into all the bits in DX.
15 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
AND: This instruction logically ANDs each bit of the source byte or word with the
corresponding bit in the destination and stores result in the destination.
OR : This instruction logically ORs each bit of the source byte or word with the
corresponding bit in the destination and stores result in the destination.
XOR : This instruction logically XORs each bit of the source byte or word with the
corresponding bit in the destination and stores result in the destination.
TEST: This instruction logically ANDs each bit of the source byte or word with the
corresponding bit in the destination and updates the flags but not stores results
in anywhere.
16 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
SAL / SHL:
• The mnemonics is SAL / SHL destination, count.
• It shift each bit in the destination to the left and 0 is stored in LSB position.
• The MSB is shifted to the carry flag.
SHR :
• The mnemonics is SHR destination, count.
• It shift each bit in the destination to the right and 0 is stored in MSB position.
• The LSB is shifted to the carry flag.
SAR:
• The mnemonics is SAR destination, count.
• It shift each bit in the destination to the right and the old MSB is stored in MSB
position.
• The LSB is shifted to the carry flag.
V. RORATE INSTRUCTIONS
ROL:
• The mnemonics is ROL destination, count.
• It rotates each bit in the destination to the left.
• The MSB is shifted to the carry flag and to the LSB position.
ROR :
• The mnemonics is ROR destination, count.
• It rotates each bit in the destination to the right.
• The LSB is shifted to the carry flag and to the MSB position.
18 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
RCR:
• The mnemonics is RCR destination, count.
• It rotates each bit in the destination to the right along with carry.
• The LSB is shifted to the carry flag and carry to the MSB position.
19 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
• These instructions are used to execute a group of instructions some number of time.
• The instructions are,
20 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
X. INTERRUPT INSTRUCTIONS
INT:
• The mnemonics is INT Type.
• It is used to call a far procedure.
• Type is referred as a number between 0 and 255, which identifies the interrupt.
• The address of the procedure is calculated by multiplying the type number by 4.
INTO: If the overflow flag is set, this instruction will cause the 8086 to call a far
procedure.
IRET: It is used to end of the ISR to return execution to the main program/.
21 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
INTERRUPT SYSTEM:
INTERRUPT is a signal applied / instruction given to the microprocessor to stop the current
process done by it and carry out a specific task requested by the interrupted device.
In response to an interrupt, the processor completes the execution of the current instruction and
transfers the program control to execute a procedure called ISR (Interrupt Service Routine).
After the complete execution of ISR, the processor returns the program control back to the
original suspended process.
A.HARDWARE INTERRUPTS:
• NMI interrupt has highest priority out of the two hardware interrupts.
• When two or more interrupts are received from different I/O devices, Intel 8259 -
Programmable Interrupt Controller is used to handle multiple interrupts.
B.SOFTWARE INTERRUPTS:
• There are 256 software interrupts with mnemonic INT followed by the interrupt
number.
• Each software interrupt is two bytes long and it has a format as shown below.
22 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
PREDEFINED INTERRUPTS:
The first five interrupts are reserved by INTEL for specific functions.
In either case, if the quotient is too large to fit in the destination registers (AL/AX) or if a
16/32-bit number is attempted to be divided by zero, then TYPE 0 – interrupt is initiated.
The user can write an ISR at the interrupt address to display the memory locations and/or the
register content to debug the program.
23 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
The first 1KB of the EPROM memory (i.e., memory address from 00000H to 003FFH) is
allocated to store the interrupt vector table (IVT). This table contains the memory address
(segment & offset address) of the ISR associated with each interrupt in 8086.
Each interrupt is allocated 4 Bytes in IVT-Interrupt Vector Table, with 2 Bytes for Segment
address and next 2 Bytes for Offset address.
In response to an interrupt, the processor loads segment and offset address into CS and IP
registers respectively to execute the corresponding ISR of the interrupt.
24 © NSS/ECE
EC1303 – Microprocessor & its applications Unit III
Part A:
1. What are the segments registers in 8086?*
2. List the merits of Memory segmentation.*
3. Name the external hardware synchronization instruction 8086 processor.*
4. What is segment override prefix? Give an example.*
5. What is the function of TEST pin in 8086 processor?*
6. How does the 8086 processor access a word at on odd address?*
7. What are the differences between 8085 and 8086?*
8. Briefly explain the interrupts in 8086.
9. Draw the Flag register and label the flags with its bit positions.
10. What is minimum and maximum mode configuration?*
11. What is meant by pipelined architecture?
12. What is the significance of Trace flag in flag register of 8086?
13. What is the significance of Interrupt flag in flag register of 8086?
14. What is the significance of Direction flag in flag register of 8086?
Part B:
* - AU questions
25 © NSS/ECE