Unit 3_Compressed (3)
Unit 3_Compressed (3)
8086 Microprocessor
Features
8 bits 8 bits
AH AL
AX Accumulator
BH BL Base
BX
CH CL Count
CX
DX DH DL
Data
SP Stack Pointer
Pointer
BP Base Pointer
SI
Source Index
Index
DI Destination Index
7
EXECUTION UNIT – General Purpose Registers
Register Purpose
AX Word multiply, word divide, word I /O
AL Byte multiply, byte divide, byte I/O, decimal arithmetic
11
EXECUTION UNIT – Flag Register
• A flag is a flip flop which indicates some conditions produced by
the execution of an instruction or controls certain operations of
the EU .
• In 8086 The EU contains a16 bit flag register
9of the 16 are active flags and remaining 7 are undefined.
6flags indicates some conditions- status flags
3flags –control Flags
U U U U OF DF IF TF SF ZF U AF U PF U CF
U - Unused 12
EXECUTION UNIT – Flag Register
Flag Purpose
Carry (CF) Holds the carry after addition or the borrow after subtraction.
Also indicates some error conditions, as dictated by some
programs and procedures .
Parity (PF) PF=0;odd parity, PF=1;even parity.
Auxiliary (AF) Holds the carry (half – carry) after addition or borrow after
subtraction between bit positions 3 and 4 of the result
(for example, in BCD addition or subtraction.)
Zero (ZF) Shows the result of the arithmetic or logic operation.
Z=1; result is zero. Z=0; The result is 0
Sign (SF) Holds the sign of the result after an arithmetic/logic
instruction execution. S=1; negative, S=0 positive
1
3
Flag Purpose
A control flag.
Trap (TF) Enables the trapping through an on-chip debugging
feature.
A control flag.
Interrupt (IF) Controls the operation of the INTR (interrupt request)
I=0; INTR pin disabled. I=1; INTR pin enabled.
A control flag.
Direction (DF) It selects either the increment or decrement mode for DI
and /or SI registers during the string instructions.
Overflow occurs when signed numbers are added or
Overflow (OF) subtracted. An overflow indicates the result has exceeded
the capacity of the Machine
1
4
BUS INTERFACE UNIT (BIU)
Contains
6-byte Instruction Queue (Q)
The Segment Registers (CS, DS, ES, SS). The Instruction Pointer (IP).
The Address Summing block (Σ)
THE QUEUE (Q)
• Whenever the queue of the BIU is not full, it has room for at least
two more bytes and at the same time the EU is not requesting it to
read or write operands from memory, the BIU is free to look ahead
in the program by pre-fetching the next sequential instruction.
1 Physical Memory
Segmented Memory
6
00000
▪The memory in an 8086/88 based
system is organized as segmented
memory. Code segment (64KB)
1 MB
1Mbyte of memory.
Extra segment (64KB)
▪The Complete physically available
memory may be divided into a Stack segment (64KB)
number of logical segments.
FFFFF
The size of each segment is 64 KB
• Each of the Segment registers store the upper 16 bit address of the
starting address of the corresponding segments.
2
0
Adder
34BA0(CS)+
8AB4(IP)
3 D 6 5 4 (next address)
44B9F
Segment and Address register
combination
• CS:IP
• SS:SP SS:BP
• DS:BX DS:SI
• Minimum mode
• Maximum mode
8086 operating Modes
• Minimum mode operation is obtained by connecting the mode
selection pin to Vcc (logic high), and maximum mode is selected by
grounding this pin.
When the Minimum mode operation is selected, the 8086 provides all
control signals needed to implement the memory and I/O interface.
• Maximum mode is used only when the • There are not enough pins on the 8086 for
system contains external coprocessors bus control during maximum mode
such as the 8087 arithmetic because new pins and new features have
coprocessor. replaced some of them.
Pin Diagram of 8086 [1]
Signals common to both the operating modes
Maximum Mode Signals
Maximum Mode Signals
ADDRESSING MODES: 8086
The different ways in which a source operand is denoted in an instruction is
known as addressing modes.
Example
MOV CX, AX ; copies the contents of the 16-bit AX register into the 16-bit CX
register), ADD BX, AX
Direct addressing mode
The addressing mode in which the effective address of the memory location is
written directly in the instruction.
Example
MOV AX, [1592H], MOV AL, [0300H]
In this addressing mode, the offset address of the operand is given by the sum
of contents of the BX/BP registers and 8-bit/16-bit displacement.
Example
MOV DX, [BX+04], ADD CL, [BX+08]
In this addressing mode, the operands offset address is found by adding the
contents of SI or DI register and 8-bit/16-bit displacements.
Example
MOV BX, [SI+16], ADD AL, [DI+16]
Based-index addressing mode
Example
ADD CX, [AX+SI]
MOV AX, [AX+DI]
In this addressing mode, the operands offset is computed by adding the base
register contents. An Index registers contents and 8 or 16-bit displacement.
Example
MOV AX, [BX+DI+08]
ADD CX, [BX+SI+16]
The 8086 microprocessor supports 8 types of instructions −
• Data Transfer Instructions
• Arithmetic Instructions
• Bit Manipulation Instructions
• String Instructions
• Program Execution Transfer Instructions (Branch & Loop Instructions)
• Processor Control Instructions
• Iteration Control Instructions
• Interrupt Instructions
8086 Instruction Format
• 8086 Instruction Format vary from 1 to 6 bytes in length.
• Fig. 6.8 shows the instruction formats for 1 to 6 bytes instructions.
• Displacements and operands may be either 8-bits or 16-bits long
depending on the instruction.
• The opcode and the addressing mode is specified using first two
bytes of an instruction.
The opcode/addressing mode byte(s) may be followed by :
• No additional byte
• Two byte EA (For direct addressing only).
• One or two byte displacement
• One or two byte immediate operand
• One or two byte displacement followed by a one or two byte
immediate operand
• Two byte displacement and a two byte segment address (for direct
intersegment addressing only).
8086 INSTRUCTION SET DATA TRANSFER INSTRUCTIONS
• MOV MOV Destination, Source
• MOV CX, 037AH Put immediate number 037AH to CX
• MOV BL, [437AH] Copy byte in DS at offset 437AH to BL
• MOV AX, BX Copy content of register BX to AX
• MOV DL, [BX] Copy byte from memory at [BX] to DL
• MOV DS, BX Copy word from BX to DS register
• MOV RESULT [BP], AX Copy AX to two memory locations; AL to the first
location, AH to the second; EA of the first memory
location is sum of the displacement represented by
RESULTS and content of BP.
Physical address = EA + SS
• MOV ES: RESULTS [BP], AX Same as the above instruction, but physical address
= EA + ES, because of the segment override prefix ES
Instruction to transfer a word
• MOV − Used to copy the byte or word from the provided source to the
provided destination.
• PUSH − Used to put a word at the top of the stack.
• POP − Used to get a word from the top of the stack to the provided
location.
• PUSHA − Used to put all the registers into the stack.
• POPA − Used to get words from the stack to all registers.
• XCHG − Used to exchange the data from two locations.
• XLAT − Used to translate a byte in AL using a table in the memory.
Instructions for input and output port transfer
• The 8086 gets the new values of CS and IP register from four memory
addresses.
• When it responds to an interrupt, the 8086 goes to memory locations to get the
CS and IP values for the start of the interrupt service routine.
• In an Interrupt Structure of 8086 system the first 1 Kbyte of memory from
00000H to 003FFH is reserved for storing the starting addresses of
interrupt service routines.
• This block of memory is often called the Interrupt Vector Table in 8086 or
the interrupt pointer table.
• Since 4 bytes are required to store the CS and IP values for each interrupt
service procedure, the table can hold the starting addresses for 256 interrupt
service routines.
Interrupt Vector Table in 8086