Microprocessor Interfacing
Microprocessor Interfacing
app/
https://www.facebook.com/duranta.ac
https://www.facebook.com/groups/govtcse.itjob/
https://www.facebook.com/smartitjobsolution
https://www.facebook.com/groups/durantabcs/
Mobile: +8801759155266
Email: [email protected]
1
Microprocessor and Microcomputer
What is Microprocessor and Microcomputer?
A microprocessor is a computer processor that incorporates the functions of a
central processing unit on a single integrated circuit, or sometimes up to 8
integrated circuits.
A microcomputer is a small, relatively inexpensive computer with a
microprocessor as its central processing unit. It includes a microprocessor,
memory and minimal input/output circuitry mounted on a single printed circuit
board
Microcontroller:
2
Microprocessor vs Microcomputer
Microprocessor:
A microprocessor is an integrated circuit that contains the central processing unit (CPU)
of a computer. It is responsible for executing instructions and performing arithmetic and
logical operations. Here are some characteristics of a microprocessor:
•Function: The primary function of a microprocessor is to process data and execute
instructions.
•Components: A microprocessor typically consists of Arithmetic Logic Unit (ALU),
Control Unit (CU), Registers, Cache Memory, Clock Generator, System Bus
•Size: Microprocessors are small in size and are usually found as a single chip.
•Usage: Microprocessors are used in various electronic devices, such as computers,
smartphones, and embedded systems.
•Examples: Intel's Pentium, AMD's Ryzen, and ARM's Cortex are examples of
microprocessors.
Microprocessor vs Microcomputer
A microcomputer is a complete computer system that includes a microprocessor, memory,
input/output devices, and other peripherals. It is a self-contained unit capable of performing
various computing tasks. Here are some characteristics of a microcomputer:
•Function: A microcomputer performs all the functions of a computer, including data processing,
storage, input/output operations, and running applications.
•Components: In addition to the microprocessor, a microcomputer includes memory (RAM and
ROM), storage devices (hard drive or solid-state drive), input/output devices (keyboard, mouse,
display), and other peripherals.
•Size: Microcomputers can vary in size, ranging from desktop computers to laptops, tablets, and
even smaller devices like smartphones.
•Usage: Microcomputers are used by individuals and organizations for general-purpose computing
tasks, such as word processing, web browsing, gaming, and running software applications.
•Examples: Personal computers (PCs), laptops, tablets, and smartphones are examples of
microcomputers
Microcontroller
It is basically a computer on a single chip.
➢Very inexpensive, small, low power
➢Convenient for use in embedded system design.
It operates on data that are fed through its serial
or parallel input ports, controlled by the software stored in on-chip memory.
Microcontrollers are small, self-contained computer systems used to control devices, with common
examples including the Arduino UNO (using an ATmega328 microcontroller) for hobbyist projects, the
ESP32 for IoT applications, and various ARM-based MCUs found in smartphones and wearables. They
are found in everyday devices like smart home appliances (microwaves, washing machines), automotive
systems, medical instruments, and industrial robotics
Often has analog input pins, timers and other utility circuitry built-in
5
Microcontroller vs Microprocessor
Microcontroller Microprocessor
It is a chip which is called single chip computer. It is a general purpose device which is
Processor Types
By Architecture:
•CISC (Complex Instruction Set Computer):
•These processors use a large set of complex instructions, which can
perform multiple operations in a single instruction but often require
more clock cycles to execute. Mostly use for Assembly Language.
•Example: Intel x86, AMD, VAX
•RISC (Reduced Instruction Set Computer):
•RISC processors have a smaller set of simple, optimized instructions
designed for rapid execution, typically in a single clock cycle. Mostly
use for High Level Language.
•Example: ARM, MIPS, RISC-V
Processor Types
জনপ্রিয় RISC িসেেসেে ধেন:
•ARM (Mobile devices, IoT, Embedded systems)
•MIPS (Routers, Game consoles যেমন PlayStation 1, 2)
•SPARC (Sun Microsystems servers)
•RISC-V (Open-source RISC architecture, এখন অসনক জনপ্রিয়)
•PowerPC (IBM, Apple এে পুসেোসনো Mac প্রেসেম, প্রকছু embedded device)
জনপ্রিয় CISC িসেেসেে ধেন:
•x86 (Intel, AMD) → আমোসেে কপ্রিউটোে, ল্যোপটসপ ব্যব্হোে হয়
•VAX (Digital Equipment Corporation) → একেময় জনপ্রিয় প্রছল্
•Z80 (Zilog) → পুেসনো মোইসরোকপ্রিউটোে ও embedded প্রেসেসম
•System/360 (IBM Mainframe) → যমইনসেম প্রেসেসম
MCQ Practice
What is the word length of the Pentium-II microprocessor?
a) 8-bit
b) 32-bit
c) 64-bit
d) 16-bit
Answer: c
Generation of
Microprocessors
First Generation of Microprocessors
The duration between 1971 and 1978 is marked as the first generation of microprocessors. It
began with the development of 4004 by Intel Corporation in the year of 1971. Where, the 4004-
microprocessor was the first microprocessor commercially available in the world. This
microprocessor was mainly designed to use in calculators to perform basic arithmetic
operations. PMOS technology was used
Intel 8086 − It is a 16-bit microprocessor with a 5 to 10 MHz clock speed. It uses the concept of
segmented memory addressing and supports larger programs.
Motorola 68000 − It is another popular third generation microprocessor with a clock speed of 4
to 16.67 MHz. This microprocessor provides a set of special instructions for BCD arithmetic. It
was commonly used in Unix workstations and Apple's MacOS systems.
Intel 80386 − It was the first x86 microprocessor with the full 32-bit architecture. It was known
for providing support for modern operating systems, virtual memory, and multitasking.
PowerPC Processor − It is a microprocessor architecture developed by AIM (Apple-IBM-
Motorola) to develop high-performance and energy efficient microprocessors.
In fourth generation of microprocessors, the major milestones have been achieved −
The on-chip L1 cache memory was introduced to reduce the memory access delays.
A higher transistor density was achieved.
Fifth Generation of Microprocessors
The duration of fifth generation of microprocessors is from 2000 to till date. This is the
generation of microprocessors started with the development of 64-bit microprocessors, having
multiple cores, and emerging capabilities like AI (Artificial Intelligence) and graphics.
The following are some popular examples of fifth generation microprocessors −
Intel Pentium 4 − This was the 32-bit microprocessor having a clock speed of greater than 3
GHz and paved the path of modern computing.
AMD x86-64 Architecture − This microprocessor architecture provides compatibility for both
32-bit and 64-bit applications.
The fifth-generation microprocessors offer the following advanced capabilities −
These microprocessors provide multi-core functionality of up to 64 cores. Hence, they provide
better performance and unparalleled multitasking capabilities.
These microprocessors also provide graphics support for gaming, video/image editing, robotics,
etc.
These microprocessors are more energy efficient.
MCQ Practice
1. Which generation of computers was the first to introduce the
microprocessor?
(a) First Generation
(b) Second Generation
(c) Third Generation
(d) Fourth Generation
Intel's Pentium processor (also known as the 80586), the two pipelines are
referred to as U and V, which stand for "U" for "Micro" and "V" for
"Vector".
•U Pipeline: This pipeline handles the execution of general-purpose instructions,
which are common in typical applications.
•V Pipeline: This pipeline is optimized for handling floating-point operations and
instructions, particularly those used in vector processing.
Multicore Processor
A multicore processor is a single chip containing two or more
independent processing units, called cores, each capable of executing
instructions. This architecture allows for parallel processing,
improving multitasking and overall device performance by letting
cores work on different tasks simultaneously or the same task on
different data. Common examples include dual-core, quad-core, and
octa-core processors found in computers, smartphones, and other
electronic devices.
Architecture of GPM and Operation
মূল্ ব্লকেমূহ:
Control Unit (CU): Memory যর্সক instruction আসন (Fetch); Decode কসে কী কোজ কেসৈ হসব্
প্রনধতোেণ কসে Execution process পপ্রেচোল্নো কসে; Arithmetic Logic Unit (ALU) Arithmetic
operations (যেোে, প্রব্সয়োে, গুণ, িোে) Logical operations (AND, OR, NOT, XOR ইৈযোপ্রে)
Registers খুব্ দ্রুৈ যছোট যমযমাপ্রে Temporary data, instruction, address েিংেক্ষণ কসে যেমন:
Program Counter (PC), Instruction Register (IR), Accumulator Cache Memory খুব্ দ্রুৈৈে
যমমপ্রে RAM এব্িং Processor-এে মসধয data েোসখ েোসৈ latency কম হয় System Bus Data
Bus → Data আেোন-িেোন Address Bus → যকোন যমমপ্রে যল্োসকশন access হসব্ ৈো প্রনসেতশ কসে Control
Bus → Read/Write, clock, interrupt প্রেেনযোল্ Main Memory (RAM) যিোগ্রোম ও data েোসখ
Processor এখোন যর্সক instruction fetch কসে Input/Output Interfaces ব্োইসেে device
(keyboard, display, disk ইৈযোপ্রে) এে েোসর্ েিংসেোে
Operation of a Microprocessor
Microprocessor েোধোেণৈ Instruction Cycle অনুেেণ কসে:
Fetch → Program Counter অনুেোয়ী Instruction memory যর্সক আনো হয়
Decode → Instruction-এে অর্ত Control Unit যব্োসে
Execute → ALU/Registers ব্যব্হোে কসে Instruction execute হয়
Store/Write Back → িল্োিল্ Register ব্ো Memory-যৈ েিংেক্ষণ হয় (এটো ব্োেব্োে হয় — েোসক
Fetch-Decode-Execute Cycle ব্ল্ো হয়)
Specific Name Example (General-Purpose Microprocessor Family) প্রকছু
জনপ্রিয় General-Purpose Microprocessor: Intel x86 Family (Core i3/i5/i7/i9,
Pentium, Celeron) AMD Ryzen (x86 based) ARM Cortex-A Series (Mobile,
Tablet, Embedded systems) MIPS processors (Networking, Embedded devices)
MCQ Practice
1. A superscalar processor is a type of processor that:
a) Can only execute one instruction per clock cycle.
b) Issues multiple instructions simultaneously, each operating on a piece of data.
c) Uses a single, fixed instruction set for all operations.
d) Cannot overlap instruction execution.
Answer: (b)
2. The "i" in "Core i" processors (e.g., Core i5, Core i7) primarily refers to:
a) The instruction set architecture (like Intel's iA32).
b) A proprietary naming convention by Intel to indicate performance tiers and families of processors.
c) The bit width of the processor (e.g., 32-bit or 64-bit).
d) The number of physical cores in the CPU.
Answer: (b)
3. A 64-bit processor can process data in chunks of:
a) 8 bits
b) 16 bits
c) 32 bits
d) 64 bits
Answer: (d) 64 bits
Addressing Modes
Immediate addressing mode
The addressing mode in which the data operand is a part of the instruction itself is known as
immediate addressing mode.
Example
MOV CX, 4929 H, ADD AX, 2387 H, MOV AL, FFH [MOV CX, 4929H is immediate
addressing because 4929H is a literal, fixed value written directly into the instruction.]
Register addressing mode
It means that the register is the source of an operand for an instruction.
Example
MOV CX, AX ; copies the contents of the 16-bit AX register into; the 16-bit CX register),
ADD BX, AX
30
Addressing Modes
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]
Register indirect addressing mode
This addressing mode allows data to be addressed at any memory location through an offset
address held in any of the following registers: BP, BX, DI & SI.
Example
MOV AX, [BX] ; Suppose the register BX contains 4895H, then the contents ; 4895H are
moved to AX
ADD CX, {BX}
31
Addressing Modes
Based addressing mode
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]
Indexed addressing mode
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]
Indexed addressing mode is used for array and list operations
32
Addressing Modes
Based-index addressing mode
In this addressing mode, the offset address of the operand is computed by
summing the base register to the contents of an Index register.
Example
ADD CX, [AX+SI], MOV AX, [AX+DI]
Based indexed with displacement mode
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]
33
MCQ Practice
When data required for instruction is present inside the register of a
microprocessor then which of the following addressing mode is used?
a) Indexed b) Register c) Relative d) Direct
Answer: b
35
Assembly Language Opcode
BSR - Bit Scan Reverse
BSWAP - Byte Swap
BT - Bit Test
BTC - Bit Test with Compliment
BTR - Bit Test with Reset
BTS - Bit Test and Set
CALL - Procedure Call
CBW - Convert Byte to Word
CDQ - Convert Double to Quad
CLC - Clear Carry
36
Assembly Language Opcode
CLD - Clear Direction Flag
CLI - Clear Interrupt Flag
CLTS - Clear Task Switched Flag
CMC - Complement Carry Flag
CMP - Compare
CMPS - Compare String
CMPXCHG - Compare and Exchange
CWD - Convert Word to Double word
CWDE - Convert Word to Extended Double word.
DAA - Decimal Adjust for Addition
37
Assembly Language Opcode
DAS - Decimal Adjust for Subtraction
DEC - Decrement
DIV - Divide
ENTER - Make Stack Frame
ESC - Escape
Floating point instuctions - no descriptions
HLT - Halt CPU
IDIV - Signed Integer Division
IMUL - Signed Multiply
IN - Input Byte or Word From Port
38
Assembly Language Opcode
INC - Increment
INS - Input String from Port
INT - Interrupt
INTO - Interrupt on Overflow
INVD - Invalidate Cache
INVLPG - Invalidate Translation Look-Aside Buffer Entry
IRET/IRETD - Interrupt Return
JA/JNBE - Jump Above / Jump Not Below or Equal
JAE/JNB - Jump Above or Equal / Jump on Not Below
JB/JNAE - Jump Below / Jump Not Above or Equal
39
Assembly Language Opcode
JBE/JNA - Jump Below or Equal / Jump Not Above
JC - Jump on Carry
JCXZ/JECXZ - Jump if Register (E)CX is Zero
JE/JZ - Jump Equal / Jump Zero
JG/JNLE - Jump Greater / Jump Not Less or Equal
JGE/JNL - Jump Greater or Equal / Jump Not Less
JL/JNGE - Jump Less / Jump Not Greater or Equal
JLE/JNG - Jump Less or Equal / Jump Not Greater
JMP - Unconditional Jump
JNC - Jump Not Carry
JNE/JNZ - Jump Not Equal / Jump Not Zero
40
Assembly Language Opcode
LODS - Load String
LOOP - Decrement CX and Loop if CX Not Zero
LOOPE/LOOPZ - Loop While Equal / Loop While Zero
LOOPNZ/LOOPNE - Loop While Not Zero / Loop While Not Equal
LSL - Load Segment Limit
LSS - Load Pointer Using SS
LTR - Load Task Register
MOV - Move Byte or Word
MOVS - Move String
MOVSX - Move with Sign Extend
41
Assembly Language Opcode
JNO - Jump Not Overflow
JNS - Jump Not Signed
JNP/JPO - Jump Not Parity / Jump Parity Odd
JO - Jump on Overflow
JP/JPE - Jump on Parity / Jump on Parity Even
JS - Jump Signed
LAHF - Load Register AH From Flags
LAR - Load Access Rights
LDS - Load Pointer Using DS
42
Assembly Language Opcode
MOVZX - Move with Zero Extend
MUL - Unsigned Multiply
NEG - Two's Complement Negation
NOP - No Operation
NOT - One's Compliment Negation
OR - Inclusive Logical OR
OUT - Output Data to Port
OUTS - Output String to Port
POP - Pop Word off Stack
43
Example: Simple x86 Assembly Code
MOV AX, 5 ; AX register এ 5 েোখো
MOV BX, 10 ; BX register এ 10 েোখো
ADD AX, BX ; AX = AX + BX
CMP AX, 15 ; AX == 15 প্রকনো ৈুল্নো কেো
JE RESULT ; েপ্রে েমোন হয়, ৈসব্ RESULT label-এ jump
MOV CX, 0 ; নো হসল্ CX = 0
RESULT:
MOV CX, 1 ; েপ্রে েমোন হয়, CX = 1
MCQ Practice
1. Suppose registers ‘A’ and ‘B’ contain 50H and 40H respectively. After instruction
MOV A, B, what will be the contents of registers A and B?
a) 40H, 40H b) 50H, 40H c) 50H, 50H d) 60H, 40H
Answer: a
2. DAA instruction is used to perform which type of addition?
a) BCD addition b) Excess-3 addition c) Binary addition d) Octal addition
Answer: a
3. Which of the following register is not used in opcode fetch operations?
a) Program counter
b) Memory address register
c) Memory data register
d) Flag register
Answer: d
8086 Microprocessor
Σ symbol (or its equivalent in mathematical notation) is a shorthand way of representing the
addition of the shifted segment address and the offset address to determine the actual memory
location.
BUS interface
1. Address Bus: The address bus is used to send the memory
address of the instruction or data being read or written. The address
bus is 16 bits wide, allowing the 8086 to address up to 64 kilobytes
of memory.
2. Data Bus: The data bus is used to transfer data between the
microprocessor and memory. The data bus is 16 bits wide, allowing
the 8086 to transfer 16-bit data words at a time.
3. Control Bus: The control bus is used to transfer control signals
between the microprocessor and other components in the computer
system. The control bus is used to send signals such as read, write,
and interrupt requests, and to transfer status information between the
microprocessor and other components.
Features of 8086 Microprocessor:
Intel 8086 was launched in 1978.
It was the first 16-bit microprocessor.
This microprocessor had major improvement over the execution speed of 8085.
It is available as 40-pin Dual-Inline-Package (DIP).
It is available in three versions:
◦ 8086 (5 MHz)
◦ 8086-2 (8 MHz)
◦ 8086-1 (10 MHz)
It consists of 29,000 transistors.
48
Bus Interface Unit (BIU)
The function of BIU is to:
Fetch the instruction or data from memory.
Write the data to memory.
Write the data to the port.
Read data from the port.
49
Instruction Queue
To increase the execution speed, BIU fetches as many as six instruction bytes
ahead to time from memory.
All six bytes are then held in first in first out 6 byte register called instruction
queue.
Then all bytes have to be given to EU one by one.
This pre fetching operation of BIU may be in parallel with execution operation
of EU, which improves the speed execution of the instruction.
50
Execution Unit (EU)
The functions of execution unit are:
To tell BIU where to fetch the instructions or data from.
To decode the instructions.
To execute the instructions.
The EU contains the control circuitry to perform various internal operations. A
decoder in EU decodes the instruction fetched memory to generate different
internal or external control signals required to perform the operation. EU has
16-bit ALU, which can perform arithmetic and logical operations on 8-bit as
well as 16-bit.
51
General Purpose Registers of 8086
These registers can be used as 8-bit registers individually or can be used as 16-
bit in pair to have AX, BX, CX, and DX.
AX Register: AX register is also known as accumulator register that stores
operands for arithmetic operation like divided, rotate.
BX Register: This register is mainly used as a base register. It holds the
starting base location of a memory region within a data segment.
CX Register: It is defined as a counter. It is primarily used in loop instruction
to store loop counter.
DX Register: DX register is used to contain I/O port address for I/O
instruction.
52
Segment Registers
53
Segment Registers
Code Segment (CS): The CS register is used for addressing a memory
location in the Code Segment of the memory, where the executable program is
stored.
Data Segment (DS): The DS contains most data used by program. Data are
accessed in the Data Segment by an offset address or the content of other
register that holds the offset address.
Stack Segment (SS): SS defined the area of memory used for the stack.
Extra Segment (ES): ES is additional data segment that is used by some of
the string to hold the destination data.
54
Flag Register of 8086
Flags Register determines the current state of the processor. They are modified automatically by CPU after
mathematical operations, this allows to determine the type of the result, and to determine conditions to
transfer control to other parts of the program. 8086 has 9 flags and they are divided into two categories:
Conditional Flags
Control Flags
55
Control Flags
Control flags are set or reset deliberately to control the operations of the execution unit.
Control flags are as follows:
Trap Flag (TP):
◦ It is used for single step control.
◦ It allows user to execute one instruction of a program at a time for debugging.
◦ When trap flag is set, program can be run in single step mode.
56
Conditional Flags
Conditional flags represent result of last arithmetic or logical instruction executed. Conditional flags
are as follows:
Carry Flag (CF): This flag indicates an overflow condition for unsigned integer arithmetic. It is
also used in multiple-precision arithmetic.
Auxiliary Flag (AF): If an operation performed in ALU generates a carry/barrow from lower
nibble (i.e. D0 – D3) to upper nibble (i.e. D4 – D7), the AF flag is set i.e. carry given by D3 bit to
D4 is AF flag. This is not a general-purpose flag, it is used internally by the processor to perform
Binary to BCD conversion.
Parity Flag (PF): This flag is used to indicate the parity of result. If lower order 8-bits of the result
contains even number of 1’s, the Parity Flag is set and for odd number of 1’s, the Parity Flag is
reset.
Zero Flag (ZF): It is set; if the result of arithmetic or logical operation is zero else it is reset.
Sign Flag (SF): In sign magnitude format the sign of number is indicated by MSB bit. If the result
of operation is negative, sign flag is set.
Overflow Flag (OF): It occurs when signed numbers are added or subtracted. An OF indicates that
the result has exceeded the capacity of machine.
57
Pin diagram of 8086
MCQ Practice
1. How many address lines are present in 8086 microprocessor?
a) 16
b) 20
c) 32
d) 40
Answer: b
2. Which of the following is a special-purpose register of microprocessor?
a) Program counter
b) Instruction register
c) Accumulator
d) Temporary register
Answer: a
MCQ Practice
3. Which of the following is true about stack pointer?
a) Stack pointer contains the address of the top of the stack memory b) Stack
pointer is an 8-bit register c) Stack pointer stores data permanently d) Stack
pointer is initialized after stack operation
Answer: a
4. Which of the following is not a status flag in microprocessor?
a) Overflow flag
b) Direction flag
c) Interrupt flag
d) Index flag
Answer: d
Popular Assembler 8086
Assembler ব্যাখ্যা
MASM (Microsoft Macro
Microsoft এর তৈরর
Assembler)
TASM (Turbo Assembler) Borland এর তৈরর
NASM (Netwide Assembler) মর্ ডান ও ওপেন সর্ার্ ড
8086 simulation-র্হ রিল্ট-ইন
EMU8086
assembler