Microprocessor and Assimbly Lecturer Material - All Chapters
Microprocessor and Assimbly Lecturer Material - All Chapters
Chapter 1
Introduction to Microprocessor
Organized by: Samuel M.
Course covers
CHAPTER 1- INTRODUCTION
Microprocessor and computer
The Microprocessor and its Architecture
CHAPTER 2- MICROPROCESSOR AND ITS FUNCTION
Modern Microprocess components and its function’s.
Basic Execution Unite and Bus Interface
CHAPTER 3- Microprocessor MEMORY
ORGANAZATION
Introduction
Main memory
Microprocessor on-chip memory management unit and cache
Course covers
CHAPTER 4: NUMBERING SYSEM
Computer data representation
Number conversation between binary to decimal
Number conversation between binary to octal
Number conversation between binary to hexadecimal
CHAPTER 5- BASICS OF ASSEMBLY LANGUAGES
Machine language Directives
Instruction operands Creating a program
Basic instructions First Compiler dependencies
CHAPTER 6: CPU INTERRUPT
Interrupt
Procedures and Functions
Assessment Overview
25%- Mid Term
25%- Sectional Marks (Assignment, Class attendance and
participation)
50%- Final Term
Student with class absence >=20% will not seat for final
exam of this course
Student with uncompleted assessment before final the
exam date will not fit to seat for final exam this course
Introduction to
Microprocessor
What is Microprocessors?
The brain or engine of the PC is the processor
(sometimes called microprocessor), or central processing
unit (CPU).
Integrated circuit that contains the entire central
processing unit of a computer on a single chip.
A microprocessor (uP) is a computer that is fabricated on
an integrated circuit (IC).
What the Cpu Perform ?
The CPU performs the system’s calculating and
processing.
6
THE MICROPROCESSOR BASED
PERSONAL COMPUTER SYSTEM …
7
CPU… 8
8
CHAPTER 2 Organized by Samuel M.
9
Data bus - carries the data between the processor and
other components.
Address bus - carries memory addresses from the
processor to other components such as primary storage
and input/output devices. The address bus is unidirectional
Control bus - carries control signals from the processor to
other components.
Microprocessors can be characterized
based on What?
The word size(data handling capacity )
8 bit, 16 bit, 32 bit, 64 bit, etc. processors
Instruction set structure
RISC (Reduced Instruction Set Computer)
CISC (Complex Instruction Set Computer)
Functions
General purpose, special purpose such image processing, floating point
calculations
Memory organization
Von-Neumann architecture
Stores data and instruction
Harvard architecture
11
Basic Terms used in Microprocessor
Bus
Set of conductors intended to transmit data, address or control
information to different elements in a microprocessor.
A microprocessor will have three types of buses: data bus, address bus, and
control bus.
IPC (Instructions Per Cycle)
It is a measure of how many instructions a CPU is capable of
executing in a single clock.
Clock Speed
It is the number of operations per second the processor can perform.
It can be expressed in megahertz (MHz) or gigahertz (GHz).
12
Basic Terms used in Microprocessor
Bandwidth
The number of bits processed in a single instruction is called
Bandwidth.
Data Types
The microprocessor supports multiple data type formats like binary,
ASCII, signed and unsigned numbers.
13
Features of a Microprocessor
Cost-effective: The microprocessor chips are available at low
prices and results its low cost.
Size: The microprocessor is of small size chip, hence is portable.
Low Power Consumption: Microprocessors are manufactured by
using metal-oxide semiconductor technology, which has low power
consumption.
Versatility: The microprocessors are versatile as we can use the
same chip in a number of applications by configuring SW program.
Reliability: The failure rate of an IC in microprocessors is very
low, hence it is reliable
Portable - Due to the small size and low power consumption
microprocessors are portable. 14
CHAPTER 2
MICROPROCESSOR PARTS
AND
FUNCTION
Processor System Architecture
The typical processor system consists of:
CPU (central processing unit)
ALU (arithmetic-logic unit)
Control Logic
Registers, etc…
Memory
Input / Output interfaces
Interconnections between these units:
Address Bus Data Bus
Control Bus
The CPU Internal Structure
The internal architecture of the 8085 CPU is capable of performing the
following operations:
19
Architecture Diagram
Microprocessor Interrupts 20
Architecture Diagram
The internal architecture of 8086 is internally decided into
two functional units:
Bus Interface Unit(BIU)
Execution Unit
Microprocessor Interrupts 21
Basic Interface Unit - BIU
Microprocessor Interrupts 22
Bus Interface Unit(BIU)
Microprocessor Interrupts 23
Bus Interface Unit(BIU)
•Segment register − BIU has 4 segment buses.
•It holds the addresses of instructions and data in memory, which are
used by the processor to access memory locations.
•It also contains 1 pointer register IP, which holds the address of the next
instruction to executed by the EU.
• CS − It stands for Code Segment. It is used for addressing a
memory location in the code segment of the memory, where the
executable program is stored.
• DS − It stands for Data Segment. It consists of data used by the
program and accessed in the data segment by an offset address
or the content of other register that holds the offset address.
• SS − It stands for Stack Segment. It handles memory to store data
and addresses during execution.
• ES − It stands for Extra Segment. ES is additional data segment,
which is used by the string to hold the extra destination data.
•Instruction pointer − It is a 16-bit register used to hold the address of
the next instruction to be executed.
Microprocessor Interrupts 24
Architecture Diagram
Microprocessor Interrupts 25
Execution Unit - Registers
▶ General registers are used for temporary
storage and manipulation of data and
instructions
▶ Accumulator register consists of two 8- bit
Microprocessor Interrupts 26
Execution Unit - Registers
▶ Base register consists of two 8-bit registers BL
and BH, which can be combined together and
used as a 16-bit register BX
▶ BX register usually contains a data pointer used
for based, based indexed or register indirect
addressing
▶ Count register consists of two 8-bit registers CL
and CH, which can be combined together and
used as a 16-bit register CX
▶ Count register can be used as a counter in string
manipulation and shift/rotate instructions
Microprocessor Interrupts 27
Execution Unit - Registers
▶ Data register consists of two 8-bit registers
DL and DH, which can be combined
together and used as a 16-bit register DX
▶ Data register can be used as a port number
in I/O operations
▶ In integer 32-bit multiply and divide
Microprocessor Interrupts 28
Execution Unit (EU): Flag
Auxiliary Carry Flag
Carry Flag
This is set, if there is a carry from the lowest
nibble, i.e, bit three during addition, or borrow This flag is set, when there is a carry
for the lowest nibble, i.e, bit three, during out of MSB in case of addition or a
subtraction. borrow in case of subtraction.
This flag is set, when the result of This flag is set, if the result of the This flag is set to 1, if the lower byte of the
any computation is negative computation or comparison performed result contains even number of 1’s ; for
by an instruction is zero odd number 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 enters
This flag is set, if an overflow occurs, i.e, if the result of a signed operation is large
the single step execution mode by
enough to accommodate in a destination 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-
generating internal interrupts after the
bit sign operations, then the overflow will be set. execution of each instruction
Interrupt Flag
Direction Flag
This is used by string manipulation instructions. If this flag bit is ‘0’, the string
is processed beginning from the lowest address to the highest address, i.e., Causes the 8086 to recognize external mask
auto incrementing mode. Otherwise, the string is processed from the highest interrupts; clearing IF disables these
address towards the lowest address, i.e., auto incrementing mode. interrupts. 2
Microprocessor Interrupts 29 9
Execution Unit - Flags
▶ Overflow Flag (OF) - set if the result is too
large positive number, or is too small negative
number to fit into destination operand
▶ Direction Flag (DF) - if set then string
manipulation instructions will auto-decrement
index registers. If cleared then the index
registers will be auto-incremented
▶ Interrupt-enable Flag (IF) - setting this bit
enables maskable interrupts
▶ Single-step Flag (TF) - if set then single-step
interrupt will occur after the next instruction
Microprocessor Interrupts 30
Execution Unit - Flags
Microprocessor Interrupts 32
Execution Unit - Pointers
▶ Stack Pointer (SP) is a 16-bit register pointing to program
stack
▶ Base Pointer (BP) is a 16-bit register pointing to data in
stack segment. BP register is usually used for based, based
indexed or register indirect addressing.
▶ Source Index (SI) is a 16-bit register. SI is used for
indexed, based indexed and register indirect addressing,
as well as a source data addresses in string manipulation
instructions.
▶ Destination Index (DI) is a 16-bit register. DI is used for
indexed, based indexed and register indirect addressing,
as well as a destination data addresses in string
manipulation instructions.
Microprocessor Interrupts 33
Chapter 3
MICROPROCESSOR
MEMORY ORGANIZATION
Microprocessor Interrupts 34
Outline
Introduction
Main memory
Microprocessor on-chip memory management
unit and cache
3
8
Microprocess and Assembly Language 35 35
Introduction
L0:
Smaller, faster, registers
and more L1: on-chip L1
expensive (per cache (SRAM)
byte) storage off-chip L2
L2:
devices cache (SRAM)
4
1
Microprocess
Microprocessor and Assembly Language
Interrupts 38 38
Main memory
An important characteristic of a
memory is whether it is
volatile or nonvolatile.
The contents of a volatile memory are
lost when the power is turned off.
RAM is a volatile memory.
A nonvolatile memory retains its contents after
power is
switched off.
ROM is a typical example of nonvolatile memory.
4
2
Microprocess
Microprocessor and Assembly Language
Interrupts 39 39
Random-Access Memory
SRAM DRAM
stores data in flip-flops (on/off stores data in capacitors.
switches).
memory does not need to be it can hold data for a few
refreshed. milliseconds, need to be refreshed
have lower densities have higher densities
DRAMs are inexpensive, occupy less space, and dissipate less power than
SRAMs.
4
3
Microprocess
Microprocessor and Assembly Language
Interrupts 40 40
Random-Access Memory
4
4
Microprocess
Microprocessor and Assembly Language
Interrupts 41 41
READ Timing Diagram
Write timing
1.When the CLK signal goes HIGH, the microprocessor
places the contents of the MAR on the address A0-
A19 of the µp chip.
2.At the same time, the microprocessor raises the
WRITE pin signal to HIGH.
3.The microprocessor places data to be stored from the
contents of an internal register onto Data bus Do-
D15.
4.The logic external to the microprocessor stores the
data from the register into a RAM location addressed
by the MAR.
4
6
Microprocess
Microprocessor and Assembly Language
Interrupts 43 43
Memory Management Concepts
4
7
Microprocess
Microprocessor and Assembly Language
Interrupts 44 44
Memory Management Concepts
4
8
Microprocess
Microprocessor and Assembly Language
Interrupts 45 45
Memory Management Concepts
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 48 48
Memory Management Concepts
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 49 49
Memory Management Concepts
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 50 50
Memory Management Concepts
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 52 52
Memory Management Concepts
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 56 56
Cache Memory Organization
Direct mapping,
Direct mapping uses a RAM for the cache.
The microprocessor’s 12-bit address is divided into two
fields, an index field and a tag field.
Because the cache address is 8 bits wide (28 =
256), the low- order 8 bits of the microprocessor’s
address form the index field, and the remaining 4 bits
constitute the tag field.
In general, if the main memory address field is m bits
wide and the cache memory address is n bits wide,
the index field will then require n bits and the tag
field will be (m - n )
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 57 57
Cache Memory Organization
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 59 59
Cache Memory Organization
Set-associative mapping.
a combination of direct and associative mapping.
cache word stores two or more main memory
words using the same index address.
Each main memory word consists of a tag and
its data word.
An index with two or more tags and data words
forms a set
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 60 60
Cache Memory Organization
Set-associative mapping.
When the microprocessor generates a memory
request, the index of the main memory address is
used as the cache address.
The tag field of the main memory address is then
compared associatively (simultaneously) with all
tags stored under the index.
If a match occurs, the desired dataword is read.
If a match does not occur, the data word, along with
its tag, is read from main memory and written into
the cache
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 61 61
Cache Memory Organization
Set-associative mapping.
The size of a set is defined by the number of tag and
data items in a cache word. A set size of 2 is used in
this example. Each index address contains two data
words and their associated tags. Each tag includes
4 bits, and each data word contains 16 bits.
Therefore, the word length = 2 x (4 + 16) = 40
bits. An index address of 8 bits can represent
256 words. Hence, the size of the cache memory is
256 x 40. It can store 512 main memory words
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 62 62
Cache Memory Organization
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 63 63
Cache Memory Organization
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 64 64
Cache Memory Organization
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 65 65
Cache Memory Organization
5
0
Microprocess
Microprocessor and Assembly Language
Interrupts 66 66
CHAPTER 4
MICROPROCESSOR
AND
ASSEMBLY LANGUAGE
Data Representation
Outline
Introduction
Numbering Systems
Binary & Hexadecimal Numbers
Base Conversions
Integer Storage Sizes
Binary and Hexadecimal Addition
Signed Integers and 2's Complement Notation
Binary and Hexadecimal subtraction
Carry and Overflow
Character Storage
stop when
37 = 100101 quotient is zero
0001 → 1
0110 → 6
1010 → A
0111 → 7
1001 → 9
0100 → 4
16A794.
M1021.swf
stop when
quotient is zero
word 16
Standard sizes:
doubleword 32
quadword 64
carry: 1
0 0 0 0 0 1 0 0 (4)
+ 0 0 0 0 0 1 1 1 (7)
0 0 0 0 1 0 1 1 (11)
bit position: 7 6 5 4 3 2 1 0
21 / 16 = 1, remainder 5
1 1 1 1 0 1 1 0
Negative
0 0 0 0 1 0 1 0 Positive
Examples:
2's complement of 6A3D = 95C3
2's complement of 92F0 = 6D10
2's complement of FFFF = 0001
0 0 0 0 1 1 1 1 15 0 0 0 0 1 1 1 1 15
+ +
0 0 0 0 1 0 0 0 8 1 1 1 1 1 0 0 0 245 (-8)
0 0 0 1 0 1 1 1 23 0 0 0 0 0 1 1 1 7
1 1 1 1
0 1 0 0 1 1 1 1 79 1 1 0 1 1 0 1 0 218 (-38)
+ +
0 1 0 0 0 0 0 0 64 1 0 0 1 1 1 0 1 157 (-99)
1 0 0 0 1 1 1 1 143 0 1 1 1 0 1 1 1 119
(-113)
Carry = 0 Overflow = 1 Carry = 1 Overflow = 1
Odd Parity: The 8th bit is set such that the total number of 1s in the 8-
bit code word is odd.
Basic Concepts
of
Assembly Language Programming
Organized by Samuel M.
Some Important Questions to Ask
What is Assembly Language?
Why Learn Assembly Language?
What is Machine Language?
How is Assembly related to Machine
Language?
What is an Assembler?
How is Assembly related to High-Level
Language?
Is Assembly Language portable?
High-Level Language: D = A * B + 10
A statement in a high-level language is translated
typically into several machine-level instructions
Source Object
File Assembler File
Link
Source Object
Assembler Libraries
File File
E.g.:
MOV CX, 037A H // move 037Ah into CX
MOV AL, BL // move BL to AL
MOV BX, [0301 H] // Move content of [0301h] into BX
Example:
LIST DB 7FH, 42H, 35H
Three consecutive memory locations are reserved for
the variable LIST and each data specified in the
instruction are stored as initial value in the reserved
memory location
Example:
Segnam SEGMENT
… Program code
…
… or
… Data Defining Statements
Segnam ENDS
Microprocess Interrupts
Organized by:
Samuel M. Organized by:
Microprocess and Assembly Language 13 Samuel M.
0
What is Interrupts?
Thank You!