CH-02 8086-microprocessor-architecture
CH-02 8086-microprocessor-architecture
(ECEg-4161)
Lecture 02
Intel 8086 MICROPROCESSOR ARCHITECTURE
8086 has a 20 bit address bus can access up to 220 memory locations (1 MB).
It has multiplexed address and data bus AD0- AD15 and A16 – A19.
It requires single phase clock with 33% duty cycle to provide internal timing.
3
Features
8086 is designed to operate in two modes, Minimum and Maximum.
4
Internal architecture of 8086
5
Internal architecture of 8086
6
Internal architecture of 8086
8086 has two blocks BIU and EU.
• The BIU handles all transactions of data and addresses on the buses for EU.
• It performs all bus operations such as instruction fetching, reading and writing
operands for memory and calculating the addresses of the memory operands.
The instruction bytes are transferred to the instruction queue.
Pointer Registers:
Stack Pointer (SP 16 bits)
It holds offset address of the top of the Stack.
Base Pointer (BP 16 bits)
BP can hold offset address of any location in the stack segment.
11
It can be used to access data in other segments
EXECUTION UNIT – Pointer And Index Registers
Index Registers:
13
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) Indicates the number of 1-bits that result from an operation.
PF=0;odd parity, PF=1;even parity.
Auxiliary Holds the carry (half – carry) after addition or borrow after subtraction
(AF) 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
14
EXECUTION UNIT – Flag Register
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 15
EXECUTION UNIT – Flag Register
• Six of the flags are status indicators reflecting properties of the last
arithmetic or logical instruction.
• For example, if register AL = 7Fh and the instruction ADD AL,1 is
executed then what will be the stet of conditional flags?
AL = 80h
CF = 0; there is no carry out of bit 7
PF = 0; 80h has an odd number of ones
AF = 1; there is a carry out of bit 3 into bit 4
ZF = 0; the result is not zero
SF = 1; bit seven is one
OF = 1; the sign bit has changed
16
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 (Σ)->Address Generation Circuit
17
BUS INTERFACE UNIT (BIU)
Functions
It provides the interface of 8086 to external memory and I/O devices.
It operates with respect to bus cycles (machine cycles). This means it performs
various machine cycles such as memory read, I/O read etc. to transfer data
with memory and I/O devices.
The BIU handles all transactions of data and addresses on the buses for EU.
It generates the 20 bit physical address for memory access.
o
• BIU fetches the next six instruction bytes from the Code Segment and stores it
into the queue.
• Execution Unit (EU) removes instructions from the queue and executes them.
The queue is refilled when at least two bytes are empty as 8086 has a 16 bit data
bus. 19
HE QUEUE (Q)
In linear addressing the entire memory space is available to the processor in one
linear array.
Each segment is 64kB in size and addressed by one of the segment registers.
21
Memory Segmentation…
22
Memory Segmentation…
Each of these segments can be used for a specific function.
Code Segment (CS)
• Contains the machine instructions that are to execute.
• Typically, the first executable instruction is at the start of this segment, and the
operating system links to that location to begin program execution.
• CS register will hold the beginning address of this segment.
Data Segment (DS)
• Contains program defined data, constants and works areas.
• DS register is used to store the starting address of the DS
Stack Segment (SS)
– Contains any data or address that the program needs to save temporarily or for used by
your own “called” subroutines.
Extra Segment(ES)
• String instruction always uses extra segment.
23
• Used for shared memory.
Physical, Offset, and Logical addresses
Physical address is the 20-bit address that is actually put on the address pins of the
8086 microprocessor and decoded by the memory interfacing circuitry. It is an actual
physical location in RAM or ROM within the 1MB memory range.
Logical address consists of a segment value and an offset address.
• Address viewed with respect to one segment (Seg.Reg : Offset)
Offset The distance(displacement) in bytes from the segment address to another location
within the segment.
• Thus the first byte of the code segment is at offset 00,the second byte is at offset 01 and so
forth.
Actual Address = Segment Address + Offset
24
Segment registers
In 8086/88 the processors have 4 segments registers
Code Segment register (CS), Data Segment register (DS), Extra Segment register (ES) and
Stack Segment (SS) register.
All are 16 bit registers.
Each of the Segment registers store the upper 16 bit address of the starting address of the
corresponding segments.
CS register
Contains the starting address of code segment.
The content of the CS register is added with the content in the Instruction Pointer (IP)
register to obtain the address of the instruction that is to be fetched for execution.
DS register
Contains the starting address of data segment.
The address in DS register will be added with the value in the address field (in instruction
25
format) to obtain the real address of the data in data segment.
Segment registers
SS Register
Contains the starting address of the stack segment.
The content in this register will be added with the content in the Stack Pointer (SP) register
to obtain the required word.
Allows the placing of code, data and stack portions of the same program in different parts
(segments) of the memory, for data and code protection.
Permits a program and/or its data to be put into different areas of memory each time program
is executed, i.e. provision for relocation may be done .
The segment registers are used to allow the instruction, data or stack portion of a program to
be more than 64Kbytes long. The above can be achieved by using more than one code, data or
stack segments.
27
Segmentation builds re-locatable and re-entrant programs easily.
Instruction pointer & summing block
Instruction Pointer (IP)
It is a 16-bit register which contains the offset address or displacement for the next
instruction in the Code Segment that will be executed by the CPU.
The value in the IP register will be added into the value in the CS register to obtain the real
address of an instruction.
Address of the next instruction is calculated as CS x 10H + IP.
IP is incremented after every instruction byte is fetched.
IP gets a new value whenever a branch occurs.
Address Generation Circuit
The BIU has a Physical Address Generation Circuit. It generates the 20 bit physical
address using Segment and Offset addresses using the formula:
Physical Address = Segment Address x 10H + Offset Address
28
Segment and Memory Addressing
29
Instruction pointer & summing block
The segment-offset scheme allows programs to be relocated in memory on 16 byte
boundaries
Address Generator
30
Addressing Modes : Memory Access
Physical Address will have to be calculated Physical Address : Actual
address of a byte in memory. i.e. the value which goes out onto the address
bus.
Memory Address represented in the form of
Seg : Offset (eg - 89AB:F012)
Each time the processor wants to access memory, it takes the contents of a
segment register, shifts it one hexadecimal place to the left (same as
multiplying by (10)16 ), then add the required offset to form the 20- bit
address
89AB : F012 89AB 89AB0 (Paragraph to byte 89AB x 10 = 89AB0)
F012 0F012 (Offset is already in byte unit)
+ -------
31
98AC2 (The absolute address)
• Example For Address Calculation (segment: offset)
• If the data segment starts at location 1000h and a data reference contains the
address 29h where is the actual data?
Segment Address
0001 0000 0000 0000 0000
32
Segment and Address register combination
• CS:IP
• SS:SP SS:BP
• DS:BX DS:SI
33