Microprocessor Chapter 2
Microprocessor Chapter 2
Microcontrollers
Focus Areas: CONTROL ENGINEERING &
COMMUNICATION ENGINEERING
UNIVERSITY OF GONDAR
INSTITUTE OF TECHNOLOGY
@2019
Microprocessor
• Microprocessor (µP) is the “brain” of a computer
that has been implemented on one
semiconductor chip.
• The word comes from the combination micro and
processor.
• Processor means a device that processes
whatever(binary numbers, 0’s and 1’s)
To process means to manipulate. It describes all
manipulation.
Micro - > extremely small
2
Definition of a Microprocessor.
The microprocessor is a
programmable device that takes in numbers,
performs on them arithmetic or logical
operations according to the program stored in
memory and then produces other numbers as
a result.
3
Microprocessor ?
A microprocessor is multi
programmable clock driven
register based semiconductor
device that is used to fetch ,
process & execute a data
within fraction of seconds.
4
Applications
• Calculators
• Accounting system
• Games machine
• Instrumentation
• Traffic light Control
• Multi user, multi-function environments
• Military applications
• Communication systems
5
Evolution of Microprocessor
First Generation ( 1939 -1954)
Vacuum Tubes
Second Generation ( 1954 -1959)
Transistor
Third Generation ( 1999 -1971)
Integrated Circuit (IC)
Fourth Generation ( 1971 -Present)
Microprocessor
Microprocessor is scaling from 4004 to Pentium 4.
Microprocessor is identified with word size of data
6
MICROPROCESSOR HISTORY
7
DIFFERENT PROCESSORS AVAILABLE
Socket
Pinless
Processor
Processor Slot
Processor
ProcessorSl
ot
8
Development of Intel Microprocessors
• 8086 - 1979
• 286 - 1982
• 386 - 1985
• 486 - 1989
• Pentium - 1993
• Pentium Pro - 1995
• Pentium MMX -1997
• Pentium II - 1997
• Pentium II Celeron - 1998
• Pentium II Zeon - 1998
• Pentium III - 1999
• Pentium III Zeon - 1999
• Pentium IV - 2000
• Pentium IV Zeon - 2001
9
GENERATION OF PROCESSORS
Processor Bits Speed
8080 8 2 MHz
8086 16 4.5 – 10
MHz
8088 16 4.5 – 10
MHz
80286 16 10 – 20
MHz
80386 32 20 – 40
MHz
80486 32 40 – 133
MHz
10
GENERATION OF PROCESSORS
Pentium 32 60 – 233
MHz
Pentium 32 150 – 200
Pro MHz
Pentium II, 32 233 – 450
Celeron , MHz
Xeon
Pentium 32 450 MHz –
III, Celeron 1.4 GHz
, Xeon
Pentium IV, 32 1.3 GHz –
Celeron , 3.8 GHz
Xeon
Itanium 64 800 MHz –
3.0 GHz
11
Intel 4004
Introduced in 1971.
12
Intel 4040
Introduced in 1971.
It was also 4-bit µP.
13
8-bit Microprocessors
14
Intel 8008
Introduced in 1972.
It was first 8-bit µP.
Its clock speed was
500 KHz.
Could execute
50,000 instructions
per second.
15
Intel 8080
Introduced in 1974.
It was also 8-bit µP.
Its clock speed was
2 MHz.
It had 6,000
transistors.
16
Introduced in 1976.
Intel 8085
It was also 8-bit µP.
Its clock speed was 3 MHz.
Its data bus is 8-bit and
address bus is 16-bit.
It had 6,500 transistors.
Could execute 7,69,230
instructions per second.
It could access 64 KB of
memory.
It had 246 instructions.
17
16-bit Microprocessors
18
Introduced in 1978.
It was created as a
cheaper version of
Intel’s 8086.
25
Introduced in 1993.
INTEL PENTIUM
It was also 32-bit µP.
26
INTEL PENTIUM PRO
Introduced in 1995.
It was also 32-bit µP.
It had 21 million
transistors.
Cache memory:
8 KB for instructions.
8 KB for data.
27
INTEL PENTIUM II
Introduced in 1997.
It was also 32-bit µP.
Its clock speed was 233
MHz to 500 MHz.
Could execute 333
million instructions per
second.
28
INTEL PENTIUM II XEON
Introduced in 1998.
29
INTEL PENTIUM III
Introduced in 1999.
It was also 32-bit µP.
Its clock speed varied
from 500 MHz to 1.4
GHz.
It had 9.5 million
transistors.
INTEL PENTIUM IV
Introduced in 2000.
It had 42 million
transistors.
Introduced in 2006.
INTEL DUAL CORE
It is 32-bit or 64-bit µP.
64-BIT MICROPROCESSORS
Intel Core 2 Intel Core i3
INTEL CORE I5 INTEL CORE I7
Basic Terms
• Bit: A digit of the binary number { 0 or 1 }
• Nibble: 4 bit Byte: 8 bit word: 16 bit
• Double word: 32 bit
• Data: binary number/code operated by an
instruction
• Address: Identification number for memory
locations
• Clock: square wave used to synchronize various
devices in µP
• Memory Capacity = 2^n ,
n->no. of address lines
37
BUS CONCEPT
• BUS: a collection of wires through which data is
transmitted
• Data: data, address or control signals
• The size of bus (its width) is how many bits it
can transfer at a time.
CLASSIFICATION OF BUSES:
1. Address Bus: sends a memory address along bus
from the CPU to the memory. To fetch/write
data, the CPU needs to tell the RAM the address
2. ADDRESS BUS: sends the actual data to and
from the memory
3. CONTROL BUS: carries commands from the
CPU and status messages from other
hardware devices 38
BUS CONCEPT
• BUS: Group of conducting lines that carries data ,
address & control signals.
CLASSIFICATION OF BUSES:
1. DATA BUS: group of conducting lines that carries
data.
2. ADDRESS BUS: group of conducting lines that
carries address.
3. CONTROL BUS: group of conducting lines that
carries control signals {RD, WR etc}
CPU BUS: group of conducting lines that directly
connected to µP
SYSTEM BUS: group of conducting lines that carries
data , address & control signals in a µP system
39
Microcomputer CONCEPT
40
TRISTATE LOGIC
3 logic levels are:
• High State (logic 1)
• Low state (logic 0)
• High Impedance state
High Impedance: output is not being driven to any defined logic level
by the output circuit.
41
Basic Microprocessors System
Central Processing Unit
Arithmetic-
Control
Logic
Unit
ProcessingUnit
Input Data into Output
Devices Information
Primary Storage Devices
Unit
Keyboard, Monitor
Mouse Printer
etc
2
THE 8086 MICROPROCESSOR
43
UNIT 2 Syllabus
• Introduction to 8086 – Features
• Memory and Memory Segmentations
• Microprocessor architecture
Bus Interface Unit Execution Unit
Instruction Queue Instruction Decoder
Segment Registers Control System
Instruction Pointer Arithmetic Logic Unit
Address Adder ( Address General Purpose
Summing Block Registers
Flag Register
Pointer & Index registers
44
8086 Microprocessor-features
INTEL launched 8086 in 1978
8086 is a 16-bit microprocessor.
8086 has a 20 bit address bus can access
up to 𝟐𝟐𝟎 = 10,48,576 bytes memory
locations (1 MB).
It provides 14, 16 -bit registers.
Word size is 16 bits.
It requires single phase clock with 33% duty
cycle to provide internal timing.
It can support upto 64K I/O ports
45
8086 Microprocessor-features cont’d
8086 is designed to operate in two modes,
Minimum and Maximum.
It can prefetches up to 6 instruction bytes from
memory and queues them in order to speed up
instruction execution.
It requires +5V power supply.
A 40 pin dual in line package.
Address ranges from 00000H to FFFFFH
Memory is byte addressable - Every byte has a
separate address.
46
8086 Microprocessor-features cont’d
8086 is a 16-bit microprocessor with
16-bit Data Bus {D0-D15}
20-bit Address Bus {A0-A19} [can access
up to [𝟐𝟐𝟎 = 1,048,576 bytes = 1 MB
memory locations] .
It has multiplexed address and data
bus AD0-AD15 and A16–A19.
47
8086 Microprocessor
8086 requires one phase clock with a
33% duty cycle to provide optimized
internal timing.
Range of clock:
• 5 MHz for 8086
• 8Mhz for 8086-2
• 10Mhz for 8086-1
48
Memory (RAM)
In memory, data is stored as bytes.
Each byte has a specific address.
Intel 8086 has 20 lines address bus.
With 20 address lines, the memory that can
be addressed is 𝟐𝟐𝟎 bytes.
𝟐𝟐𝟎 = 1,048,576 bytes (1 MB).
8086 can access memory with address
ranging from 00000 H to FFFFF H.
49
Memory Segmentation
Segmentation is the process in which the
main memory of the computer is logically
divided into different segments and each
segment has its own base address.
The total memory size is divided into
segments of various sizes.
Segment is just an area in memory.
The process of dividing memory this way is
called Segmentation.
50
Memory Segmentation
8086 has a 20-bit address bus
So it can address a maximum of 1MB of
memory
8086 can work with only four 64KB segments
at a time within this 1MB range
These four memory segments are called
• Code segment
• Stack segment
• Data segment
• Extra segment
51
Memory
64KB Memory 1
00000H
2
Segment
3
4
4
5
Only 4 such segments can be 6
addressed at a time 7
8
1MB
9 Address
10 Range
11
12
13
14
15
16
FFFFFH
52
Code Segment
That part of memory from where BIU is
currently fetching instruction code bytes
Stack Segment
A section of memory set aside to store
addresses and data while a subprogram
executes
53
Memory
Code Segment 1
00000H
2
4
Data & Extra 5
Segments 6
8
1MB
9 Address
10 Range
11
12
13
14
15
55
8086 Internal Architecture
8086 has two blocks BIU and EU.
The BIU handles all transactions of data and
addresses on the buses for EU.
The BIU performs all bus operations such as
instruction fetching, reading and writing
operands from/to memory and calculating the
addresses of the memory operands. The
instruction bytes are transferred to the
instruction queue.
EU executes instructions from the instruction
system byte queue.
56
Bus Interface Unit
Sends out addresses for memory locations
Fetches Instructions from memory
Reads/Writes data to memory
Sends out addresses for I/O ports
Reads/Writes data from/to Input/Output
ports
57
Execution Unit
Tells BIU (addresses) from where to
fetch instructions or data, decodes
& Executes instructions
58
Architecture Diagram of 8086
59
Instruction Decoder
Control System
49
Execution Unit
Main components are
• Instruction Decoder
• Control System
• Arithmetic Logic Unit
• General Purpose Registers
• Flag Register
• Pointer & Index registers
61
Execution Unit
62
Instruction Decoder
Translates instructions fetched from memory
into a series of actions which EU carries out
Control System
Generates timing and control signals to
perform the internal operations of the
microprocessor (Directs the internal operations)
73
Flag Register
8086 has a 16-bit flag register
Contains 9 active flags
There are two types of flags in 8086
• Conditional flags – six flags, set or reset
by EU on the basis of results of some
arithmetic operations
• Control flags – three flags, used to control
certain operations of the processor
74
Flag Register
U U U U OF DF IF TF SF ZF U AF U PF U CF
1. CF CARRY FLAG
Conditional Flags
2. PF PARITY FLAG
(Compatible with 8085,
3. AF AUXILIARY CARRY
except OF)
4. ZF ZERO FLAG
5. SF SIGN FLAG
6. OF OVERFLOW FLAG
7. TF TRAP FLAG
Control Flags
8. IF INTERRUPT FLAG
9. DF DIRECTION FLAG
75
Flag Register
Auxiliary Carry Flag
Carry Flag
This is set, if there is a carry from the
lowest nibble, i.e, bit three during This flag is set, when there is
addition, or borrow for the lowest a carry out of MSB in case of
nibble, i.e, bit three, during addition or a borrow in case
subtraction. of subtraction.
This flag is set, when the This flag is set, if the result of This flag is set to 1, if the lower
result of any computation the computation or comparison byte of the result contains even
is negative performed by an instruction is number of 1’s ; for odd number of
zero 1’s set to zero.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OF DF IF TF SF ZF AF PF CF
Tarp Flag
Over flow Flag If this flag is set, it will work in a
This flag is set, if an overflow occurs, i.e, if the result of a signed single step mode. After each
operation is large enough to accommodate in a destination instruction, one internal interrupt
register. The result is of more than 7-bits in size in case of 8-bit is generated. It helps to execute
signed operation and more than 15-bits in size in case of 16-bit some program instruction by
sign operations, then the overflow will be set. instruction.
Direction Flag Interrupt Flag
This is used by string manipulation instructions. If this flag bit
is ‘0’, the string is processed beginning from the lowest If IF = 1, then MPU will recognize
address to the highest address, i.e., auto incrementing mode. the interrupts from peripherals. For
Otherwise, the string is processed from the highest address IF = 0, the interrupts will be 54
ignored
towards the lowest address, i.e., auto incrementing mode.
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 the following happen
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 77
Registers, Flag
8086 registers
categorized 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
into 4 groups OF DF IF TF SF ZF AF PF CF
80
Bus Interface Unit
81
Instruction Queue
8086 employs parallel processing
When EU is busy decoding or executing current
instruction, the buses of 8086 may not be in use.
At that time, BIU can use buses to fetch upto six
instruction bytes for the following instructions
BIU stores these pre-fetched bytes in a FIFO
register called Instruction Queue
So that the execution unit gets the instructions
for execution in the order they are fetched.
When EU is ready for its next instruction, it simply
reads the instruction from the queue in BIU
82
Pipelining
EU of 8086 does not have to wait in
between for BIU to fetch next
instruction byte from memory
So the presence of a queue in 8086
speeds up the processing
Feature of fetching the next instruction
while the current instruction executes
is called pipelining
83
Memory Segmentation
Segmentation is the process in which the
main memory of the computer is logically
divided into different segments and each
segment has its own base address. It is
basically used to enhance the speed of
execution of the computer system, so that
the processor is able to fetch and execute
the data from the memory easily and fast.
84
Memory Segmentation
8086 has a 20-bit address bus
So it can address a maximum of 1MB of
memory
8086 can work with only four 64KB segments
at a time within this 1MB range
These four memory segments are called
• Code segment
• Stack segment
• Data segment
• Extra segment
85
Memory
64KB Memory 1
00000H
2
Segment
3
4
4
5
Only 4 such segments can be 6
addressed at a time 7
8
1MB
9 Address
10 Range
11
12
13
14
15
16
FFFFFH
86
Code Segment
That part of memory from where BIU is
currently fetching instruction code bytes
Stack Segment
A section of memory set aside to store
addresses and data while a subprogram
executes
87
Memory
Code Segment 1
00000H
2
4
Data & Extra 5
Segments 6
8
1MB
9 Address
10 Range
11
12
13
14
15
89
Segment Registers
hold the upper 16-bits of the starting
address for each of the segments
The four segment registers are
• CS (Code Segment register)
• DS (Data Segment register)
• SS (Stack Segment register)
• ES (Extra Segment register)
90
Segment Registers and Segmentation
91
Memory
1 00000H
CS 1000 0H Code Segment
3
Starting Addresses
8
1MB
9
of Segments Address
10
Range
11
12
13
14
15
93
Max. size of Segment
94
95
Address of a segment is of 20-bits
A segment register stores only upper 16-
bits
BIU always inserts zeros for the lowest 4-
bits of the 20-bit starting address.
E.g. if CS = 348AH, then the code
segment will start at 348A0H
A 64-KB segment can be located
anywhere in the memory, but will start at
an address with zeros in the lowest 4-bits
96
Physical Address Generation
In order to calculate the physical
address, we need to master the
concept of:
Memory Segmentation and the
Segments
Segment Registers
Index and pointer Registers
97
Instruction Pointer and summing block
Instruction Pointer (IP) Register
a 16-bit register
Holds 16-bit offset, of instruction in the
code segment that is to be executed
next.
The IP always references the Code
segment register (CS).
BIU uses IP and CS registers to
generate the 20-bit address of the
instruction to be fetched from memory.
98
Instruction Pointer and summing block
The value contained in the instruction pointer
is called as an offset because this value must
be added to the base address of the code
segment, which is available in the CS register
to find the 20-bit physical address.
The value of the instruction pointer is
incremented after executing every instruction.
To form a 20bit address of the next instruction,
the 16 bit address of the IP is added (by the
address summing block) to the address
contained in the CS , which has been shifted
four bits to the left. 99
Physical Address Generation
The BIU has a dedicated adder for
determining physical memory addresses
10
0
Physical Address Generation
Example:
If the data segment starts at location
1000h and a data reference contains
the address 29h where is the actual
data?
Offset: 0000000000101001
Segment: 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0
Address: 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 01 0 0 1
10
1
Physical Address Generation
103
Physical Address Calculation Memory
Start of Code Segment 1 00000H
348A0H Data
Segment
IP = 4214H 3
4
Code Byte 38AB4H MOV AL, BL
Code
Segment
Extra
Segment
7 1MB
8 Address
9
Range
CS 348A0 H 10
11
IP + 4214 H 12
Physical Address 38AB4 H 13
14
15
Stack
68
Segment FFFFF H
Stack Segment (SS) Register
Stack Pointer (SP) Register
Upper 16-bits of the starting address of
stack segment is stored in SS register
It is located in BIU
SP register holds a 16-bit offset from the
start of stack segment to the top of the
stack
It is located in EU
10
5
Other Pointer & Index Registers
Base Pointer (BP) register
Source Index (SI) register
Destination Index (DI) register
Can be used for temporary storage of data
Main use is to hold a 16-bit offset of a data
word in one of the segments
10
6
Segment and Address register
combination
CS:IP
SS:SP SS:BP
DS:BX DS:SI
DS:DI (for other than string operations)
ES:DI (for string operations)
10
7
Summary of Registers & Pipeline of
8086 µP
10
8
Where to Look for the Offset
10
9
Question
11
0
Solution
11
1