Microprocessor
Microprocessor
Microprocessor:
• The central processing unit built on a single IC is called
Microprocessor.
• A microprocessor (sometimes abbreviated as μP) is a digital electronic
component with miniaturized transistors on a single semiconductor
integrated circuit (IC).
• One or more microprocessors typically serve as a central processing
unit (CPU) in a computer system or handheld device.
Concept of Microprocessor
A Micro-Computer
• As the name implies, microcomputers are small computers.
• The block diagram of the microcomputer is similar to the computer except that
the central processing unit of the microcomputer is contained in a single IC called
the microprocessor.
Microprocessor
Input Unit (ALU+ Register Output Unit
array+ control unit)
Memory
Concept of Microprocessor
Microcomputer:
• A digital computer, in which one microprocessor has been provided to
act as a CPU, is called Microcomputer.
• A desktop computer, laptop, notebook, palmtop, etc. contain one
microprocessor to act as a CPU and hence they come under the
category of microcomputer.
• The term microcomputer is generally synonymous with personal
computer.
Concept of Microprocessor
Multiprocessor System:
• The CPU of a large powerful digital computer contains more than one
microprocessor.
• High-end powerful servers, mainframe computers, supercomputers,
etc. contain more than one microprocessor to act as CPU.
• A computer whose CPU contains more than one microprocessor is
called Multiprocessor System.
Concept of Microprocessor
Microcontroller:
• A highly integrated chip that contains all the components such as
CPU, RAM, some form of ROM, I/O ports, and timers is called
Microcontroller.
• Unlike a general-purpose computer, which also includes all of these
components, a microcontroller is designed for a very specific task to
control a particular system.
Functions of a Microprocessor
• The processor first fetches and instruction from the main memory.
• The instruction is then decoded to determine what action is required to
be done.
• Based on instruction the processor fetches, if required, data from main
memory or I/O module.
• The instruction is then executed which may require performing arithmetic
or logical operations on data.
• In addition to execution, CPU also supervises and controls/I/O devices.
• Finally, the results of an execution may required transfer of data to
memory or an I/O Module.
Microprocessor Characteristics
Clock Speed:
• The clock speed determines the number of operations per second the
processor can perform.
• Clock speeds are expressed in megahertz (MHz) or gigahertz (GHz).
• It is also called Clock Rate.
Microprocessor Characteristics
Word Length:
• It depends upon the width of internal data bus, registers, ALU etc.
• An 8-bit microprocessor can process 8 bit data at a time.
• The word length ranges from 4 bits for small microprocessor, to 64
bits for high-end microcomputers.
Microprocessor Characteristics
Width of Data Bus: This is the size of the data bus. It defines the
number of bits that can be transferred through data bus.
1.ADD AL, BL
2.ADD AL, o5H
Bus Interface Unit(BIU)
BIU performs the following functions-
• It generates the 20 bit physical address for memory access.
• It fetches instruction from memory.
• It transfers data to and from the memory and I/O.
• It supports pipelining using the 6 byte instruction queue
Execution Unit (EU)
Execution Unit (EU) performs the following functions-
• It fetches instructions from the Queue in BIU, decodes and executes
them.
• It performs arithmetic, logic and internal data transfer operations
within the microprocessor.
• It sends request signals to the BIU to access the external module.
Main Components of Bus Interface Unit (BIU)
The main components of the BIU are as follows:
4 Segment Registers
Instruction Pointer
Address Generation Circuit and
A prefetch queue
Main Components of BIU (Cont.)
Segment registers-
• CS register: CS holds the base address for the Code Segment. All programs are stored in
the Code Segment. CS is multiplied by 10H to give the 20 bit physical address of the Code
Segment. E.g. If CS = 4321H then CS x 10H = 43210H→ Starting address of Code
Segment.
• DS register: DS holds the base address for the Data Segment. It is multiplied by 10H to
give the 20 bit physical address of the Data Segment. E.g. If DS = 4321H then DS x 10H =
43210H→ Starting address of Data Segment.
• SS register: SS holds the base address for the Stack Segment. It is multiplied by 10H to
give the 20 bit physical address of the Stack Segment. E.g. If SS = 4321H then SS x 10H =
43210H→ Starting address of Stack Segment.
• ES register: ES holds the base address for the Extra Segment. It is multiplied by 10H to
give the 20 bit physical address of the Extra Segment. E.g. If ES = 4321H then ES x 10H =
43210H→ Starting address of Code Segment.
Main Components of BIU (Cont.)
Instruction Pointer (IP)-
• It is a 16 bit register. It holds offset of the next instructions in the
Code Segment.
• 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
Main Components of BIU (Cont.)
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
Main Components of BIU (Cont.)
6 Byte Pre-fetch Queue:
• It is a 6 byte queue (FIFO).
• Fetching the next instruction (by BIU from CS) while executing
the current instruction is called pipelining.
• Gets flushed whenever a branch instruction occurs.
Main Components of Execution Unit (EU)
The main components of the EU are as follows:
• General purpose registers-
• 8086 microprocessor has four 16 bit general purpose registers AX, BX, CX and DX.
These are available to the programmer for storing values during programs. Each of
these can be divided into two 8 bit registers such as AH, Al; BH, BL; etc. Beside their
general use, these registers also have some specific functions.
• AX register (16 bits): It holds operands and results during multiplication and division operations.
All I/O data transfers using IN and OUT instructions use A register (AL/AH or AX). It functions as
accumulator during string operations.
• BX register (16 bits): It holds the memory address (offset address) in indirect addressing modes.
• CX register (16 bits): It holds count for instructions like loop, rotate, shift and string operations.
• DX register (16 bits): It is used with AX to hold 32 bit values during multiplication and division. It
is used to hold the address of the I/O port in indirect I/O addressing mode.
Main Components of EU (Cont.)
Special purpose registers-
• Stack Pointer (SP 16 bits): It holds offset address of the top of the Stack.
Stack is a set of memory locations operating in LIFO manner. Stack is present in
the memory in Stack Segment. It is used during instructions like PUSH, POP,
CALL, RET etc.
• Base Pointer (BP 16 bits): BP can hold offset address of any location in the
stack segment. It is used to access random locations of the stack.
• Source Index (SI 16 bits): It is normally used to hold the offset address for
Data Segment but can also be used for other segments using Segment
Overriding. It holds offset address of source data in Data Segment during string
operations.
• Destination Index (DI 16 bits): It is normally used to hold the offset address
for Extra Segment but can also be used for other segments using Segment
Overriding. It holds offset address of destination in Extra Segment during string
Main Components of EU (Cont.)
• ALU (Arithmetic Logic Unit) - It has a 16 bit ALU. It performs 8 and 16
bit arithmetic and logic operations.
• Operand register- It is a 16 bit register used by the control register to
hold the operands temporarily. It is not available to the programmer.
Main Components of EU (Cont.)
• Instruction Register and Instruction Decoder- The EU fetches an
opcode from the queue into the instruction register. The instruction
decoder decodes it and sends the information to the control circuit
for execution.
Offset for the Specific Segment
This is set, if there is a carry from the This flag is set, when there is
lowest nibble, i.e, bit three during a carry out of MSB in case of
addition, or borrow for the lowest addition or a borrow in case of
nibble, i.e, bit three, during subtraction. 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 is the computation or byte of the result contains even
negative comparison performed by an number of 1’s ; for odd number
instruction is zero of 1’s set to zero.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
U U U U OF DF IF TF SF ZF U AF U PF U CF
Trap 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
interrupts after the execution of
signed operation and more than 15-bits in size in case of 16-bit
each instruction
sign operations, then the overflow will be set.
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 Causes the 8086 to recognize
address to the highest address, i.e., auto incrementing mode. external mask interrupts; clearing
Otherwise, the string is processed from the highest address IF disables these interrupts.
towards the lowest address, i.e., auto decrementing mode. 56
Flag Register Calculation
• Example:
1. Identify flag registers for the following operations of Hexadecimal
numbers:
• i. 41+4F
• ii. 37+01
• iii. 9E+D3
Flag Register Calculation (Solution)
• Example:
1. Flag registers for the following operations of Hexadecimal numbers:
• i. 41+4F (CF=0, SF=1, PF=1, ZF=0, OF=1, AF=1)
8086 registers 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
categorized into
groups
OF DF IF TF SF ZF AF PF CF
Opcode Operand
Addressing Mode
• IMPORTANT TERMS
• Starting address of memory segment.
• Effective address or Offset: An offset is determined by adding any
combination of three address elements: displacement, base and
index.
• Displacement: It is an 8 bit or 16 bit immediate value given in the instruction.
• Base: Contents of base register, BX or BP.
• Index: Content of index register SI or DI.
Types of 8086 Addressing Mode
The 8086 has 8 basic addressing modes:
1) Immediate addressing mode
2) Register addressing mode
3) Direct memory addressing mode
4) Register based indirect addressing mode
5) Register relative addressing mode
6) Indexed addressing mode
7) Base indexed addressing mode
8) Relative based indexed addressing mode
9) Implied addressing mode
Types of Addressing Mode
1) Immediate addressing mode-
• In this mode, the operand is specified in the instruction itself.
Instructions are longer but the operands are easily identified.
• Example:
• MVI CL, 12H
MOV CL, 12H
• The effective address (EA) of source data is stored in SI register and the EA of destination is stored in DI register.
• Operations:
• (MAE) (MA)
DEC AL
DEC D D=D–1 DEC [CX] memory
DEC [1000] direct memory
CBW none converts signed byte to CBW
word
Arithmetic Instruction
OPCODE OPERAND EXPLANATION EXAMPLE
CMP AX, CX
CMP Mem/Reg1, Mem/Reg1-Mem/Reg1
Mem/Reg1 Subtract two values AX-CXflag [modify]
Never store subtract
result
Arithmetic Instruction
OPCODE OPERAND EXPLANATION EXAMPLE
ASCII adjust
AAA none accumulator after AAA
addition
ASCII adjust
AAS none accumulator after AAS
subtraction
ASCII adjust
AAM none accumulator after AAM
multiplication
ASCII adjust
AAD none accumulator after AAD
division
Logical Instruction
OPCODE OPERAND DESTINATION EXAMPLE
OR D, S D = D OR S OR AX, BX