Professional Documents
Culture Documents
COMI Unit2
COMI Unit2
UNIT II : INTRODUCTION TO
MICROPROCESSORS AND
PROCESSOR ORGANIZATION
8086 Features
2
16-bit processor
16-bit data bus and 20-bit address bus
20-bit memory address and 16-bit I/O address
Provides fourteen 16-bit registers
Multiplexed lines
Perform bit, byte, word and block transfer
Operate in min and max mode
Multiprogramming
Fetch up-to six instruction bytes from memory and stores it in queue
Supports different addressing modes
Block Diagram of 8086
3
Memory Organization of 8086
4
Instruction Queue
5
Instruction Pointer
6
Common signals
AD0-AD15 (Bidirectional)
Address/Data bus
MINIMUM / MAXIMUM
READY
RESET (Input)
CLK
CS contains the base or start of the current code segment; IP contains the
distance or offset from this address to the next instruction byte to be fetched.
BIU computes the 20-bit physical address by logically shifting the contents of
CS 4-bits to the left and then adding the 16-bit contents of IP.
That is, all instructions of a program are relative to the contents of the CS
register multiplied by 16 and then offset is added provided by the IP.
Points to the current data segment; operands for most instructions are fetched
from this segment.
The 16-bit contents of the Source Index (SI) or Destination Index (DI) or a 16-
bit displacement are used as offset for computing the 20-bit physical address.
Architecture
18
The 20-bit physical stack address is calculated from the Stack Segment (SS) and
the Stack Pointer (SP) for stack instructions such as PUSH and POP.
In based addressing mode, the 20-bit physical stack address is calculated from
the Stack segment (SS) and the Base Pointer (BP).
Points to the extra segment in which data (in excess of 64K pointed to by the
DS) is stored.
String instructions use the ES and DI to determine the 20-bit physical address
for the destination.
Architecture
19
Instruction Queue
A group of First-In-First-Out (FIFO) in which up to 6 bytes of
instruction code are pre fetched from the memory ahead of time.
AL in this case contains the low order byte of the word, and AH
contains the high-order byte.
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
zero of 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, the processor
This flag is set, if an overflow occurs, i.e, if the result of a signed
enters the single step execution
operation is large enough to accommodate in a destination
mode by generating internal
register. The result is of more than 7-bits in size in case of 8-bit
signed operation and more than 15-bits in size in case of 16-bit interrupts after the execution of
sign operations, then the overflow will be set. each instruction
3. Direct Addressing
5. Based Addressing
Group II : Addressing modes for memory
6. Indexed Addressing data
7. Based Index Addressing
8. String Addressing
Addressing Modes
25
8. String Addressing
Addressing Modes
26
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
Addressing Modes
27
Addressing Modes
28
6. Indexed Addressing
Content of the DS register is used for base
address calculation.
7. Based Index Addressing
Example:
8. String Addressing
MOV CX, [BX]
9. Direct I/O port Addressing
Addressing Modes
memory data
29
In Based Addressing, BX or BP is used to hold the
1. Register Addressing base value for effective address and a signed 8-bit
or unsigned 16-bit displacement will be specified
2. Immediate Addressing in the instruction.
Addressing Modes
memory data
30
Addressing Modes
31
1. Register Addressing
In Based Index Addressing, the effective address
2. Immediate Addressing is computed from the sum of a base register (BX
or BP), an index register (SI or DI) and a
3. Direct Addressing displacement.
Addressing Modes
32
Addressing Modes
33
These addressing modes are used to access data from
1. Register Addressing standard I/O mapped devices or ports.
Addressing Modes
34
Addressing Modes
35
1. Register Addressing
2. Immediate Addressing
3. Direct Addressing
NMI
It is a single non-maskable interrupt pin (NMI) having higher priority than
the maskable interrupt request pin (INTR)and it is of type 2 interrupt.
When this interrupt is activated, these actions take place −
Completes the current instruction that is in progress.
Pushes the Flag register values on to the stack.
Pushes the CS (code segment) value and IP (instruction pointer) value of
the return address on to the stack.
IP is loaded from the contents of the word location 00008H.
CS is loaded from the contents of the next word location 0000AH.
Interrupt flag and trap flag are reset to 0.
8086 Hardware Interrupts
39
INTR
The INTR is a maskable interrupt because the microprocessor will be
interrupted only if interrupts are enabled using set interrupt flag
instruction. The INTR interrupt is activated by an I/O port.
These actions are taken by the microprocessor −
First completes the current instruction.
Activates INTA output and receives the interrupt type, say X.
Flag register value, CS value of the return address and IP value of the
return address are pushed on to the stack.
IP value is loaded from the contents of word location X × 4
CS is loaded from the contents of the next word location.
Interrupt flag and trap flag is reset to 0
8086 Software Interrupts
40
The interrupt vector (or interrupt pointer) table is the link between an
interrupt type code and the procedure that has been designated to service
interrupts associated with that code. 8086 supports total 256 types i.e. 00H
to FFH.
For each type it has to reserve four bytes i.e. double word. This double
word pointer contains the address of the procedure that is to service
interrupts of that type.
The higher addressed word of the pointer contains the base address of the
segment containing the procedure. This base address of the segment is
normally referred as NEW CS.
The lower addressed word contains the procedure’s offset from the
beginning of the segment. This offset is normally referred as NEW IP.
Thus NEW CS: NEW IP provides NEW physical address from where user
ISR routine will start.
Interrupt Vector Table
43
As for each type, four bytes (2 for NEW CS and 2 for NEW IP) are
required; therefore interrupt pointer table occupies up to the first 1k bytes
(i.e. 256 x 4 = 1024 bytes) of low memory.
The total interrupt vector table is divided into three groups namely,
A. Dedicated interrupts (INT 0…..INT 4)
B. Reserved interrupts (INT 5…..INT 31)
C. Available interrupts (INT 32…..INT 225)
80386
44
80386 Features
45
Architecture
46
47
Bus Interfacing Unit
48
Code Prefetch Unit
49
Instruction Decode Unit
50
Segmentation Unit
51
Paging Unit
52
Execution Unit
53
Registers in 80386
54
CPU must:
Fetch instructions
Interpret instructions
Fetch data
Process data
Write data
Hence, organization requirements are,
ALU, control logic, temporary storage, and means to
move data in and out of CPU
CPU With Systems Bus
63
CPU Internal Structure
64
Single Bus Organization
65
Multiple Bus Organization
66
Multiple Bus Organization
67
What is an instruction set?
68
Ways of Classification
According to function
According to number of addresses
Data processing
Data storage (main memory)
Data movement (I/O)
Program flow control
Number of Addresses (a)
74
3 addresses
Operand 1, Operand 2, Result
a = b + c;
Not common
2 addresses
One address doubles as operand and result
a=a+b
1 address
Implicit second address
0 (zero) addresses
All addresses implicit
push b
add
pop c
c=a+b
How Many Addresses
76
More addresses
More complex (powerful?) instructions
More registers
Inter-register operations are quicker
Fewer instructions per program
Fewer addresses
Less complex (powerful?) instructions
More instructions per program
Faster fetch/execution of instructions
Instruction Set Design Decisions
77
(1)
Operation repertoire
How many ops?
What can they do?
How complex are they?
Data types
Instruction formats
Length of op code field
Number of addresses
Instruction Set Design
78
Decisions(2)
Registers
Number of CPU registers available
Which operations can be performed on which
registers?
Addressing modes
RISC v CISC
Types of Operand
79
Addresses
Numbers
Integer/floating point
Characters
ASCII etc.
Logical Data
Bits or flags
Types of Operation
80
Data Transfer
Arithmetic
Logical
Conversion
I/O
System Control
Transfer of Control
CISC Complex Instruction Set
81
Compiler
Very few general purpose registers
Complex instruction set
Difficult to pipeline
Many addressing modes
Multiple Cycle Execution
Eg. CISC
Approach
MUL A, B
CISC Architecture
82
Advantages
Microprogramming is easy to implement and much
less expensive than hard wiring a control unit.
It is easy to add new commands into the chip without
changing the structure of the instruction set.
This architecture makes the efficient use of main
memory since the complexity (or more capability) of
instruction allows to use less number of instructions to
achieve a given task.
The compiler need not be very complicated, as the
micro program instruction sets can be written to match
the constructs of high level languages
CISC Disadvantages
84
Disadvantages
A new or succeeding versions of CISC processors
consists early generation processors in their subsets
(succeeding version). Therefore, chip hardware and
instruction set became complex with each generation
of the processor.
The overall performance of the machine is reduced
because of slower clock speed.
The complexity of hardware and on-chip software
included in CISC design to perform many functions.
RISC Reduced Instruction Set
85
Compiler
Large number of general purpose registers
Limited and simple instruction set
Emphasis on optimising the instruction pipeline
It optimizes the usage of register
Simple addressing modes
One Cycle Execution
It simplifies the compiler design by using identical general
purpose registers which allows any register to be used in any
context.
The number of bits used for the opcode is reduced
In general there are 32 or more registers in the RISC.
RISC Architecture
86
Eg. RISC
Approach
LOAD R1,3
LOAD R2, 5
PROD R1,R2
STORE R1, A
RISC Pipelining
RISC Advantages
88
RIS
C Vs
CIS
C
Co Processor
91
A 5 Stage Pipeline
Instruction-Level Parallelism(2)
97
Multiprocessors
Multicomputers
References
100