Micro Insight PDF
Micro Insight PDF
Insights on
MICROPROCESSORS
-~;:::;
B.E. [TU, PU, PoU, KU], BEIT,
B~cnll, BIM, BIT, BCA
CONTENTS
Ciidhirii
INTRODUCTION
1. 1 Introduction to Microprocessor ........ ... .................. .................. ..... .. 1
1.2 Microprocessor as a CPU (MPU) ..... ... ..... ..... .. .. .. ....... .......... .. .... .... I
1.3 Organization of a Microprocessor-Based System ...... ......... .... ..... ...4
1.4 Bus Organization .................................................... ............ .... ... .... . 6
1.5 Historical Background of the Development of Computers ...... ....... 7
1.6 Stored-Program Concept and Von-Neumann Machine ... ..... ... ..... 10
I. 7 Harvard Architecture .......... .......... .. ... ................................ ... ..... ... 11
1.8 Evolution of Microprocessors (Intel Series) .... .. .......... .. ... ...... ..... . 13
1.9 Processing Cycle of a Stored-Program Computer ...... .. ........ .... .. .. 15
1. IO Micro-Operations and Microinstructions ............................ .... ...... 17
1.1 1 Control Unit... ...... ........... .. ................. .. ......................... ......... ....... I 9
1.12 Register Transfer Language (RTL) .. .......... ....... ...... ..................... 20
I. 13 Applications of Microprocessors ................ ..... ... ... ... ........ ..... ....... 30
tlihhh44
PROGRAMMING WITH 8085 MICROPROCESSOR
2.1 Internal Architecture of 8085 Microprocessor .... ....... ................... 32
2.2 Characteristics (Features) of 8085 Microprocessor ................ .. .... 36
2.3 Instruction Description and Format .. .. .. ............. ........................... 39
2.4 Classification of an Instruction .................... .................. .. ... ... ..... .. 41
2.5 Addressing Modes ...... ............. ....... ........................ :...................... 70
2.6 Time Delay and Counter.. ................ ...... ............ ...... .. .... ... .... ........ 72
2.7 Number Conversion ................................ ................................ ..... . 74
2.8 Multiplication and Division ................................... ... .. ... ......... ...... 82
ADDITIONA!, QUESTIONS...................................................... 84
tlifihhiii
PROGRAMMING WITH 8086 MICROPROCESSOR
3.1 Introduction ........................... ... ... ....................... ............. .. ......... 100
3.2 Internal Architecture of 8086 Microprocessor ............................ 100
3.·3 Instructions in 8086 .......................... .. ...... ... ................... ............ 107
3.4 Operators in 8086 .............................................. ....... ........... .. .. ... 113
3.5 Coding in Assembly Language .. .. .. .. ........... ............................. ... 115
3.6 Assembling, Linking, and Executing .......................................... 123
3. 7 .COM Programs and .EXE Programs ......................................... 126
ADDITIONAL QUESTIONS.................................................... 150
j§j@I! MICROPROCESSOR SYSTEM
· o£8085 .... ..... ...... .. .... .. ................ ........ .. ..... .. .. 189
-=== Chapter-I!
p· Configuration
4.1
4.2
m
Pin Configuration o
£8086 ........ ........ ................ .............. . 194
·:::::::::: ............................ .. ..... ..... ....... 198
INTRODUCTION
1:~ :sc~t:c;;l~~·~~d·B;~·Timing.~'.~~~~~~..~:..~.~~.~................... 201
Microprocessor .. ......................... .
1.1 Introduction to Microprocessor
4.5 Read and Wnte Bus Timing of 8086 Microprocessor ................ 209 A microprocessor is a multipurpose, programmable, clock-
driven, register-based electronic device that reads binary
4.6 Memory Devi~~sg........................... :·::::::::::::::::::::::::::::::::::::::::::: ~~~
4. 7 Address Oeco ID ......................... • instn;ctions from a storage device called memory, accepts binary
8 Input/Output Devices ............... •.. •• .. ·· .... ·.. ···· .. ·.. ····· .. ··· .. · .. ·· ···.. •••• 226 data as input and processes data according to those instructions,
44. 9 Bit and Baud rate .......................................... .............. ........ ........ 246 and provides results as output.
· Standards in Serial I/O ....................... ·.... ·.. · ·.. · · .... ·· · · .... · · · · · · · · · · · · ·· · 24 7
44.10 Introduction to Direct Memory Access (DMA) & DMA A typical programmable machine can be represented with
.l I Controllers ..................................................... ··· ················ ·········· 253 four components: microprocessor, memory, input, and output as
AJJDITIONAL QUESTIONS.................................................... 257 showh in Figure 1.1. These four components work together or
[•Mfu&i interact with each other to perform a given task; thus, they
INTERRUPT OPERATIONS comprise a system. The physical components of this system are
5.1 Introduction ................................................ ... .............. ............... 270 called hardware. A set of instructions written for the microprocessor
52 Polling versus Interrupt ............................... ............................... 27 I to perform a task is called a program, and a group of programs is
5.3 Interrupt Structures ......................................... ...... .......... ............ 272 called software. The fact that the microprocessor is programmable
5.4 Interrupt Processing Sequence ........................................ ............ 274
means it can be instructed to perform given tasks within its
5.5 Multiple Interrupts and Priorities .......................... .................. .... 276 capability.
5.6 Interrupts Types ................................................................ .......... 278
5. 7 Interrupts in 8085 ...... ....... ... .... ... ...... .. ....... ......... ... ..................... 280
5.8 Interrupts in 8b86 ................................. .................. .................... 287 i -- - Memory
5.9 Priority Interrupt Controller (PIC) .............. ................................ 292
Giitifu&I Microprocessor i -- - , Input
ADVANCED TOPICS
6. 1
6.2 Multiprocessing Systems ........................................................... 295
6.3 :ta! and Pseudo-Parallelism ...................................................... 297 Output
6.4 1 Ynn's Classification ........................................ .............. ........... 298
Pnstrullctlmn Level, Thread Level, and Process Level
ara e ism ......... ..
Figure 1.1 A programmable machine
6.5 Inter-Process Co ....... :... ··:··--·•· .. ·····--···· --·--··········· ····················· 301
Deadlock mmumcation, Resource Allocation, and 1.2 Microprocessor as a CPU (MPU)
!~~
6.6
6.7 Traditionally, the computer is represented with four
~r;:;:i;tg~·;~;~~·::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::~::::
6.8 components: memory, input, output, and central processing unit
RISC and C~~r~pArrocessor Architectures ..................................... 313
6.9 . ch1tectures 314 (CPU), which consists of the arithmetic logic unit (ALU) and the
The Digital Signal Processor (D·s·p·--•--....................................... 31 7
APPENDIX ) .......................................... . control unit (CU). The CPU contains various registers to store data,
Bib/iograph; .................. .. ........... ........ ...... .. ................................ 319
322
INn"ROOUCTION 11
. an d Jo<Tical operations, . instruction With the advancement in technology, manufacturers were
rithmebc o-
able to place memory and 1/0 interfacing circuits along with MPU
h A LU to perfo rm a i·nes The CPU reads mstructions
t c d contro I 1 ·
on a single chip; this is known as a microcontroller or microcontroller
d..xodl'rs, counters, ~n d performs the tasks specified. It
from the memor~ . an/ tput devices (I/0 devices) either to unit (MCU) . Figure 1.4 shows the block diagram of a
nth inpu t ou microcontroller.
wrnmunicates \ _ he I/0 devices are also known as
acc,•pl or to send da ta, t
Microcontroller
pcnp/icru l<
.. ...CPU MPU
Arithmetic/
Logic Unit
(ALU)
Memory I/0
Input
Output
Peripheral Devices
• AID Converter
• Timer
Figure J.2 Trnditionnl block diagram of ri computer. • Serial 1/0
The advent of integrated circuit technology made possible to Figure 1.4 Block diagram of a microcontroller
build the CPU on a single chip; this was coined microprocessor. A
Differences Between Microprocessor and Microcontroller
computer with a microprocessor as its CPU is known as a
microcomputer The terms microprocessor and microprocessor unit The differences between microprocessor and microcontroller
('v1PU) are often used synonymously. MPU implies a complete
are·
processing unit with the necessary control signals. Because of the Microprocessor Microcontroller
li mited number of available pins on a microprocessor package, ·
A microprocessor is a silicon A microcontroller is an integrated
some of the signals (such as control and multiplexed signals) need
chip representing a central chip that contains a CPU,
to be generated by using discrete devices to make the
microprocessor a complete functional unit or MPU. processing unit (CPU), which is scratchpad RAM, special and
capable of performing general purpose resister arrays, on
arithmetic, as well as logical chip ROM/FLASH memory for
operations according to a program storage, timer and
Jnput Microprocessor as predefined set of instructions. interrupt contirol units, and
CPU Output dedicated 1/0 ports.
It is a dependent unit. It It is a self-contained unit and it
requires the combination of doesn't require external interrupt
other chips like timers, controller, timer, UART, etc, for its
Memory
program and data memory functioning,
Figure 1.3 Block d,u m .,
0
gro 1 11 cvmputer with the microprocessor as CPU chips, interrupt controllers, etc.
for functioning.
2
INSIGHTS ON MICROPROCESSORS
INTRODUCTION 3
Microcontroller
Microprocessor a. Arithmetic/logic unit: It performs arithmetic operations
of Microcontrollers are mostly such as addition and subtraction, and logic operations
:Microprocessors are mo st
the time general purpose in application-oriented or domain- such as AND, OR, and XOR.
design and operation. specific.
b. Register array: 1bis part consists of various registers
It does not contain a built in Most of the processors contain identified by letters such as B, C, D, E, H , and L. These
I/ O port. The I/0 port multiple built-in 1/0 ports which registers are primarily used to store data temporarily
functiona lity needs to be can be operated as a single 8- or during the execution of a program and are accessible to
implemented with the help of 16- or 32-bit port or as individual the user through instructions.
external programmable port pins. c. Control unit: It provides the necessary timing and
peripheral interface chips like control signals to all the operations in the
8255. microcomputer. It controls the flow of data between the
microprocessor and memory and peripherals.
1.3 Organization of a Microprocessor-Based System
ii. Memory
Microprocessor-based system includes three components:
microprocessor, inpuVoutput, and memory (read-only memory Memory stores binary information such as instructions and
and read/write memory) . Figure 1.5 shows a simplified structure data, and provides that information to the microprocessor
of a microprocessor-based system. whenever necessary. To execute programs, the
microprocessor reads instructions and data from memory
Microprocessor
and performs the computing operations in its ALU section.
1/0 Results are either transferred to the output section for
Input/Output
display or stored in memory for later use. The memory block
ALU Register has two sections:
Array
a. Read-only memory (ROM): The ROM is used to store
programs that do not need alterations. Programs stored
in ROM can only be read; they cannot be altered.
Memory
Control b. Read/write memory or random-access memory
~B
Figure 1.5 Micraprocessor-based system with bus architecture
(RAM): It is also known as user memory which is used to
store user programs and data. The information stored
i. Microprocessor in this memory can be easily read and altered.
It is a communication path between the microprocessor anct • The address lines are used . to designate the source/
destination of data on data bus.
peripherals; it is nothing but a group of wires to carry bits.
• The control lines are used to control the access to and the use
1.4 Bus Organization of the data and address lines. Because data and address lines
are shared by all components, there must be a means of
Bus is a group of lines used to transfer bits between the
controlling their use. Control signals transmit both
microprocessor and other components of the computer system. It is
command and timing signals. Timing signals indicate the
a common channel through which bits from any sources can be
· validity of data and address information. Command signals
transferred to the destination. A typical digital computer has many
specify operations to be performed. Control lines include
registers, and paths must be provided to transfer instructions from
memory read/ write, I/ 0 read/ write, bus request/ grant,
one register to another. The number of wires will be excessive if
clock, reset, interrupt request/ acknowledge etc.
separate lines are used between each register and all other registers
in the system. A more efficient scheme for transferring information 1.5 Historical Background of the Development of
between registers in a multiple register configuration is a common Computers
bus system. A bus structure consists of a set of common lines, one
For understanding the historical background of the
for each bit of a register, through which binary information is
development of computers, it is a wise decision to classify
transferred one at a time. Control signals determine which register
computers under mechanical and electronic era.
is selected by the bus during each particular register transfer.
1. Mechanical Era
The mechanical computer namely difference engine and
analytical engine developed by Charles Babbage, the father of
Microprocessor computer can be considered as the forerunners of modern digital
computers.
The difference engine was a mechanical device that could add
and subtract, and could only run a single algorithm. It's output
Figu're 1.6 Bus organization system was incompatible to write on punched cards and early
A very easy way of constr . optical disks. The analytical engine provided more advanced
with multiplexers The . uctmg a common bus system is features. It consisted mainly four components: the store (memory),
1 1
whose binary info;matio 1:1uhtip exers select the source register the mill (computation unit), input section (punched card reader),
n is t en placed on the bus.
and output section (punched and printed output). The store
A. system bus consists of about 5
each assigned a Particular . 0 to 100 of separate lines consisted of 1000s of words of 50 decimal digits used to hold
-
many different bus des·1mearung or funcrion. A!though there are variables and results. The mill could accept operands from the
. d into
class if1e . three furt gners,
. on any bus, th e lines can be
store; add, subtract, multiply, or divide them; and return a result to
lines. In addition, there m~tiyobnaI group~: data, address and control the store.
e power d1str·b · .
6 INSIGHTS ON MIC l Uhon lines as well.
ROPROCESSORS
INTRODUCTION 7
2. Electronic Era
the prov1s10n of system software with the computer. In 1957,
The First Generation: Vacuum Tubes Digital Equipment Corporation (DEC) was founded, and in that
The ENIAC (Electronic Numerical Integrator And year, delivered its first computer, the PDP-1. IBM developed 7090
Calculator), designed and constructed at the University of in 1960, 7094 I in 1962, and 7094 II in 1964 (successive products had
Pennsylvania, was the world's first general-purpose electronic increased performance, capacity, and/ or low cost).
digital computer. The ENIAC was a decimal rather than a binary
machine. That is, numbers were represented in decimal form, and
The Third Generation: Integrated Circuits
arithmetic was performed in the decimal system. It's memory Throughout the 1950s and early 1960s, electronic equipment
consisted of 20 accumulators, each capable of holding a IO-digit was composed largely of discrete components - transistors,
decimal number. A ring of 10 vacuum tubes represented each resistors, capacitors, and so on. Discrete components were
digit. manufactured separately, packaged in their own containers, and
soldered or wired together onto masonite-like circuit boards,
In 1947, Eckert and Mauchly formed the Eckert-Mauchly \
which were then installed in computers, oscilloscopes, and other
Computer Corporation. Their first successful machine was the electronic equipment. Whenever an electronic device called for a
UNIVAC I (Universal Automatic Computer). It was the first transistor,' transistor had to be soldered to a circuit board. T.he
successful commercial computer. It was intended for both scientific entire manufacturing process, from transistor to circuit board, was
and commercial applications. This computer was thought to expensive and cumbersome.
perform matrix algebraic computations, statistical problems,
The use of the integrated circuit defines the third generation
premium billings for a life• insurance company, and logistical
of computers. The entire circuit was fabricated in a tiny piece of
problems. The UNIVAC II, which had greater memory capacity
silicon. Initially, only a few gates or memory cells could be reliably
and higher performance than the UNIV AC I, was delivered in the
late 1950s. manufactured and packaged together. These early integrated
circuits are referred to as small-scale integration (SSI) The most
Later in 1953, IBM introduced its first electronic stored- important members of the third generation are: IBM System/360
program computer, the 701, and was intended primarily for and the DEC PDP-8. These computers were small enough that it
sc1entif1c applica_tions. In 1955, IBM delivered the companion 702 could be placed on top of a lab bench or be built into other
product that suited for business applications Th equipment.
. ese computers
establis h ed IBM as the overwhelmin 1 d .
manufacturer. gY 0 rrunant computer Later Generations
The Second Generation: Transistors . Beyond the third generation, there is less general agreement
on defining generations of computers. Based on advances in
The first major change in the electr .
the replacement of th . onic computer came with integrated circuit technology, there have been a number of later
transistor is smaller he vacuum tube by the transistor. The generations. With the introduction of large-scale integration (LSI),
' c eaper and diss· t 1 more than 1000 components can be placed on a chip. Very-large-
vacuum tube. The f ' ipa es ess heat than a
use o the transistor d f" scale integration (VLSI) achieved more than 10,000 components per
generation of compute Th e mes the second
· rs. e second chip, while current ultra-large-scale integration (ULSI) chips can
introduction of more co 1 . generation saw the
mp ex anthmeti d contain more than one billion components.
control units, the use of high-I I c an logic Units and
eve progra .
mrrung languages, and
8 INSIGHTS .ON MICROPROCESSORS
INTRODUCTION 9
l.6 Stored-Program Concept and Von-Neumann
of control unit and ALU are called registers and the various models
Machine: of registers are:
.
Accor d mg to this concept' instructions . are stored in
ory to enable it to perform. a variety of • MAR (memory address register) - contains the address in
computer mem . tasks in
· termittently The idea was mtroduced m the late memory of the word to be wriUen into or read from the
sequence or m · MBR.
1940s by John Von-Neumann, who proposed_ that a program be
electronically stored in binary-number format m a memory device • MBR (memory buffer register) - consists of a word to be
so that instructions could be modified by the computer as stored in memory or sent to the I/0 unit, or is used to
determined by intermediate computational results. Other receive a word from memory or from the I/0 unit.
engineers, notably John W. Mauchly and J. Presper Eckert, • IR (instruction register) - contains the 8-bit op-code
contributed to this idea, which enabled digital computers to instruction being executed.
become much more flexible and powerful.
• IBR (instruction buffer register) - used to temporarily hold
The task of entering and altering the programs for the the instruction from a word in memory.
ENIAC was extremely tedious. The programming process could be
• PC (program counter) - contains the address of the next
facilitated if the program could be represented in a form suitable instruction to be fetched from memory.
for storing in memory alongside the data. Then, the computer
could get its instructions by reading them fx:om memory, and a • AC & MQ (accumulator and multiplier quotient) -
program could be set or altered by setting the values of a portion of employed tq hold temporarily operands and results of ALU
memory. This approach is known as stored-program concept, and operations. For example, the result of multiplying two 40-bit
I
such architecture is named as Von-Neumann architecture. numbers is an 80-bit number; the most significant 40 bits are
; . : stored in the AC and the least sigriificant in the MQ.
INTRODUCTION
I"
Address Program Memory Address Bus Harvard architecture Von-Neumann architecture
Bus
2t========~~~~;=;;~;;;;;;c=======
v Data Memory Address Bus 2. Easier to pipeline, so high 2. Low performance
, . , ~---~-,---=-------:.:----r----.- performance can be achieved compared to Harvard
architecture
Control PC Data
Bus Control Central Related Memory Progra Data 3. Comparatively high cost 3. Cheaper
+ - - - + Unit ALU Hardware Address Memo Memory
AU 4. No memory alignment 4. Allows self modifying
problems. codes
Program Memory Data Bus 5. Since data memory and 5. Since data memory and
program memory are stored program memory are
Data Memory Data Bus
physically in different locations, stored physically in the
no changes for accidental same chip, chances for
Figure 1.8 Haroard architecture corruption of program memory. accidental corruption of
TI1e control unit controls the sequence of operations. Central program memory.
ALU consists of ALU, multiplier, accumulator, and scaling chief
register. The PC is used to address program memory and always 1.8 Evolution of Microprocessors (Intel Series)
contains the address of next instruction to be executed. Here, data The evolution of microprocessor is dependent on the
and control buses are bidirectional and address bus is development of integrated circuit technology from single scale
unidirectional.
integration (SSI) to giga scale integration (GSI).
Differences Between Harvard and Von-Neumann Table 11 Evolution of microprocessors (Intel series)
Architecture
Date Microprocessor Data Bus Address Bus Memory
Figure 1.9 differentiates the Harvard concept with Von- 1971 4004 4 bit 10 bit 640 Bytes
Neumarm concept.
1972 8008 8 bit 14 bit 16K
1974 8080 8 bit 16 bit 64K
Program
Memory CPU Data
Memory 1976 8085 8 bit 16 bit 64K
Single shared bus
(a)
1978 8086 16 bit 20 bit lM
Figure 1. 9 Harvard V N (b)
1979 8 bit 20 bit
vs on- eumann architecture (a) Von-Neumann 8088 lM
h
arc llecture (b) Harvard architecture
1982 80286 16 bit 24 bit 16M
The differences between H
architecture are· arvard and Von-Neumann 1985 80386 32 bit 32 bit 4G
Harvard architecture 1989 80486 32 bit 32 bit 4G
1. Separate buses for Von-Neumann architecture
instruction 1993 Pentium· 32/64 bit 32 bit 4G
and data fetching 1. Single shared bus
for
instruction and 1995 Pentium pro 32/64 bit 36 bit 64G
data
fetching
12 INSIGHTso
I"
N MICROPROCESSORS -----------
INTRODUCTION
Date Microprocessor Data Bus Address Bus
Memory
Pentium II 64 bit 36 bit
1997 61c • 80486: The 80486 introduced the use of much m ore
1998 Celeron 64 bit 36 bit sophisticated and powerful cache technology and
61c
sophisticated instruction pipelining, and offered a built-in
1999 Pentium III 64 bit 36 bit 64G---- math coprocessor.
2000 Pentium IV 64 bit 36 bit 64G----- • Pentium: This processor introduced the use of superscalar
2001 Itanium 128 bit 64 bit 64G ~ teclmiques, that is, ability to execute multiple instructions in
2002 Itanium 2 128 bit parallel.
64 bit 64G -
2003 Pentium M/ Centrino (wireless capability) for Mobil~ • Pentium Pro: Along with the-features of Pentium, Pentium
version e.g. Laptop Pro enabled use of register renaming, branch prediction,
2006 Dual Core (32-bit or 64-bit processor) - data flow analysis, and speculative execution.
2006 Core 2 Series (64-bit processor)- Dual and Quad Core • Pentium II: The Pentium II incorporated Intel MMX
Processor technology, which\is designed specifically to process video,
2008 audio, and graphics data efficiently. ~
Atom (32-bit or64-bit processor) - Single or Dual
Core Processor • Pentium III: This version offered additional floating-poirtt
2010 Core i3 (Dual Core Processor) irtstrw;:tions to support 3D graphics software.
2009 • Core: This is the first Intel x86 microprocessor with a dual
Core iS (Dual and Quad Core Processor)
2008 core, that is, two processors on a sirtgle chip
Core i7 (Dual and Quad Core Processor)
2011 Core i7 Extreme Edition • Core 2: The Core 2 is a 64-bit architecture. The Core 2 Quad
2017 Core i9 X-series provides four processors on a single chip.
. So'.1'e of the highlights of the evolution of the Intel product 1.9 Processing Cycle of a Stored-Program Computer
hne are listed below:
The basic function performed by a computer is execution of
• 8080: The world's first g 1 . a program, which consists of a set of irtstructions stored irt
. enera -purpose microprocessor. This
was an 8-b1t machin •h memory. Each instruction has two parts: one is the task to be
Th 8080 . e, wit an 8-bit data path to memory.
e was used m the f t performed, called the operation code (op-code) field, and the
rrs personal computer, the Altair.
• 8086: A far more po f 1 . second is the data to be operated on, called the operand or address
addressing a 1 MB fwer u, 16-bit machine which enabled field. The processor does the actual work by executing instructions
o memory and · th f1
the x86 architectu A . ' is e rst appearance of specified in the program. In its simplest from, instruction processing
re. vanant of thi 8
was used in IBM' fir processor, the 8088, consists of two steps: The processor reads (fetches) instructions
s st personal computer
• 80286· Thi · from memory one at a time and executes each irtshuction. Program
. s ts an extension of 8086 w . execution consists of repeating the process of instruction fetch and
a 16 MB memory. hich enabled addressing
instruction execution. The irtstruction execution may involve
• 80386: Intel's first 32-bit . several operations and depends on the nature of the irtstruction.
multitasking microprocessor that d
_ :___ supporte The processing required for a single instruction is called an
14\'~ R _ _ _ _ _ _
I 0CESSORS - ---
INTRODUCTION I
instruction cycle. Program execution halts only if the machine is
turned off, some sort of umecoverable error occurs, or a progr¾\
instruction that halts the computer is encountered. Fetch
Fetch Cycle Exceute Cycle
INTRODUCTION
I,
cvcle of clock is caJJed as I-state. The lower i~struction level
patterns which are the numerous_sequences for a sm~le instruction
are known as micromstructwns. We can visualize th
• Control unit issues READ command .
m icroinstruction with the help of any machine cycle. Here e • Result (data from memory) appears on data bus.
We
consider the fetch cycle. • D~ta from data bus is copied into MBR.
CPU • PC is incremented by 1
• Data (instruction) is moved from MBR to IR.
• MBR is now free for further data fetches.
Memory
Symbolically, fetch sequence is completed in 3 clock cycles.
T1: MAR f-- PC
T2: MBR f-- [MARJ
T3: PC f-- PC +1
IRf--MBR
Address Data Control where T; = time unit or clock cycle.
Bus Bus Bus
Figure 1.13 Data flow in fetch cycle. 1.11 Control Unit
Various registers involved in fetch cycle are: The control unit is the heart of CPU. It gets instruction from
• Memory Address Register (MAR) memory. The control unit decides what the instructions mecll). and
connected to address bus directs the necessary data to be moved from memory to ALU. It
must comr:tmnicate with both ALU and main memory. It
specifies address for read or write op-code
coordinates all activities of processor unit, peripheral devices, and
• Memory Buffer Register (MBR) storage devices.
connected to data bus The functions of control unit include:
holds data to write • Sequencing
• Program Counter (PC) Causing the CPU to step through a series of micro-
operations
holds address of next instru ti
. c on to be fetched • Execution
• Instruction Register (IR) Causing the performance of each micro-operations
holds last instruction fetched
Two types of control unit can be implemented in computing
The fetch sequence can be explained as follow . systems: hardwired control unit and micro-programmed control unit.
• Address of · s. 1. Hardwired Control Unit
next mstruction . .
to memo dd is m PC. This dd .
ry a ress register (MAR a ress 1s moved This control unit is essentially a combinational circuit. In
• Address from MAR . ). hardwired control unit, for each control signal, Boolean
is placed on add
ress bus. expression has to be derived for that signal as a function of
18
INSIGHTS ON MICRQp _
RocessoRs --: - - - - _ the inputs. Hardwired control unit has faster mode of
INTRODUCTION I"
.
opera hon. A hardwired control unit needs rewiring if design
has to be modified.
i. The program counter contains the address of the next
2. Micro-Programmed Control Unit
instruction to be executed. If the next instruction to be
In a modem complex processor, the number of Boolean executed is MOV A, B; the program counter contains the
equations needed to define the control uni~ is very large. The address of the memory location where the instruction code
task of implementing a hardwired control unit that satisfies for MOV A, B resides.
all of these equations becomes extremely difficult. The result In the first operation of fetch cycle, the contents of program
is to opt for a far simpler control unit, known as micro- counter will be transferred to the memory address register
programmed con trol unit. (MAR). The memory address register then uses the address bus
to transmit its contents that specifies the address of memory
In micro-programmed control unit, the logic of the control unit
location from where that instruction code of MOV A, B is to be
is specified by a microprogram. A microprogram consists of a
fetched. Let T1 indicates the period of first operation
sequence of instructions in a microprogramming language.
These are very simple instructions that specify micro-- T1 : MARf-PC
operations. Modifications in micro-programmed control unit ii. When the control unit issues the memory read signal, the
can be done by changing the microinstructions. contents of the address memory location specified by MAR
will be transferred to the memory buffer register (MBR).
1.12 Register Transfer Language (RTL) Suppose T2 is the time period for this operation.
The symbolic notation used to describe the micro-operation T2: MBR f- [MAR]
transfers amongst registers is called register transf~r language (RTL). iii. Finally the contents of MBR will be transferred to the
It is one of the forrns of hardware description language (HDL). The instruction register and then the program counter gets
t~rm _"register transfer" implies the availability of hardware logic incremented. Let T3 be the time required by the CPU ·to
circmts that can perform a stated micro-operation and transfer the complete these operations.
result of the operation to the same or another register. The term T3: IRf-MBR
"language" i~ borrowed from programmers, who apply this term PCf-PC+ 1
to programming languages.
Execute Cycle
_RTL is the convenient tool for describing the internal
organization of digital computers in concise and precise manner. It After the fetch cycle is completed, the execution starts. The
can also be used to facilitate th d • execute cycle steps are described as follows:
such as microprocessors.
• e esign process of digital systems
i. At the start of execution cycle, the instruction register (IR)
An Example of RTL consists of instruction code for instruction MOV A, B. The
address field of instructions specifies the addresses of the
Consider the execution of instructio .
of two machine cycles name] fi n MOVA, B that consists two memory locations A & B. The first step needed is to
y etch cycle and execution cycle. obtain the data from the location B. For this, the address
Fetch Cycle
field of IR indicating the address of memory location will be
Within the fetch cycle th transferred to address bus through the MAR. Let T1 be this
' e operations performed are: time taken.
20
INSIGHTS ON r•mtROPROCESSORS T1 : MAR f- (IR(Address of B))
INTRODUCTION
ii. When the control unit issues a mem~ry read signaJ, the
contents of location B will be output (wntten) to t~e :rne:rnory 3. MOVR,M
buffer register (MBR). Now t~e conte:11t of_ B which is to be
written to memory location A 1s contained m MBR. Let be r ~ T1 : MAR +-PC
the time taken for that operation. 2
~~ T2 : MBR +-[MARJ
T2 : MBR f- (B) ~ "'
"<:: <.)
;:,-,
T3 :
Q:;' ou
<..)
IR +- MBR, PC+-PC + 1,
iii. Now, we need the memory !~cation of A _because it is being
;::..
8- T4: Unspecified
written with the data of location B. For this the address field ~ "<::
of IR indicating the address of memory location A Will be 's- Cl
Ts: MAR
"' +-HL
transferred to MAR in time T3. ~ Q:;
i:' <a
"'
T6: MBR
Q:; Q ;:,-, +- [MARJ
T3 : MAR f- (IR(Address of A)) £: u T7: R +-MBR
~
"'
iv. When the control unit issues the memory write signal, the
contents of MBR will be written to the memory location 4. ,
MOV MR
indicated by the contents of MAR in time T4.
ii
.... T1: MAR +-PC
T4: A f- MBR or T4 : [MARJ f- MBR ~~ T2: MBR +-[MARJ
Note: [MAR] = A i:i::: "' <..)
i la'
<..)
T3, IR +- MBR, PC+-PC + 1,
Program consists of instructions which contains different ;::..
8- T4: Unspecified
cycles like fetch and execute. These cycles in turn are made up of
the smaller operations called micro-operations.
~ ~
's- i:' Ts: MAR f-HL
Some RTL Examples ~ Q a,
<..)
T6:
i:i::: £: "' MBR +-R
1. MOVRd, Rs ~ ·i:: T1: [MARJ +-MBR
~
"'
i::i:: ~ T1:
~":!' ~cu ~ MAR +-PC 5. MVIM, 8 - b"1t D aa
t
<.) T2:
I:;~ ~0' MBR +-[MARJ .i:::
i::i:: 0 <.) T3: ~ T1 : MAR +-PC
IR ~~
~ ~ Tc +- MBR, PCf-PC+l T2: MBR +- [MARJ
Unspecified "'
"<:: <..)
;:,-, '--
2. ou T3: IR +-MBR, PC+-PC+l
MVI R, 8-b1t Data <..)
;:... T4: Unspecified
~
~ T1 : Cl 0
~~ T2 : MAR +-Pc 0
-l:!
<::t ~ <.) MBR ~-"t:: i:' u"' Ts: MAR +-PC
c::i at T3: +-[MARJ O,::i
Q 0'
~] IR ~ ob !-.:: T6: MBR +-[MARJ
I:; ~ C' Tc +- MBR, PC+-PC+l
Unspecified i:i:::i ~ ~
i:i:::
T1: z +- MBR, PC +-PC + 1
~
i::i:: e::' ~
~ t' -~ Ts: MAR +-Pc
~
~ (.,) T6: Ta: MAR +-HL
~~~ MBR i:' ·i::"' <a"'
+- [MARJ 0 T9: MBR f-Z
Cl:: T7:
- R i~a' Tio:
---
22 +- MBR, Pc +-Pc + l [MARJ f-MBR
INSIGHTso
INTRODUCTION I"
6. LXI RP, 16-bit Data
~
....'
1,0
C
i:' i:i"'
(J
Ts: MAR f---PC t T4 : Unspecified
Q' E'l:I T6: MBR f--- [MARJ
"' <:,t
>< :E"' T1: RPL f--- MBR, PC f---PC + 1 "'~"' i:' C,"'
Ts: MARf-PC
...i r:i:: "<:I C cJ' T6 : MBRf-[MAR]
~ . "<:I
'et: E "<:I
~ i:' 1"' Ts: MAR f---PC
·-'
..... ~ ~ Ti : z f--- MBR, PC f-PC + 1
R::: C <J
,.Q i:r::
E 'I:! T9: MBR f---(MAR] l,C)
T--1
"' <:,t "<:I
:E R:::"' Tio: RPtt f---MBR,PCf---PC + 1 ~
V)
...
<:,t Ts: MARf-PC
i:r:: ...
~ i:' C, T9: MBRf-[MARJ
7. LOA 16-bit Address ,..:i
h C cJ'
~ T1: MARf---PC i:r:: j Tio : W f- MBR, PC f---PC + 1
...
"'
"' ;:,,
<J
~ T2: MBRf---[MAR]
'IS .!!: Tn: MARf---WZ
3u T3: IR f--- MBR, PCf-PC + 1 i:' <J
0
!:l..
T4: U~pecified
C cJ' T12: MBRf---A
£ ...
~ ·i: T13: [MARJ f--- MBR
'I:!
<:,t Ts: ~
\
<I)
"' MAR f-PC
j r:i::
t' i:i
C
"'
G'
T6:
MBRf-[MAR]
9. LDAXRp
~ I
,)
I ....
~
....'
1,0
I T1: z f- MBR, PC f-PC + 1
...i::
.;:l
~ .!!:
... <J
T1 :
T2:
MARf-PC
MBR f-[MAR]
'IS
~ <:,t
"'
Ts:
MARf-PC
l G'
<J
T3 : IR · f--- MBR, PCf-PC + 1
~
>-.1
~
~"'
t' i:i T9: t T4: Unspecified
~
R:::
I
C G'
Tio:
MBR f- [MARJ
~
'-l .!!:
<J
W f- MBR, PC f-PC + 1 'c;--
"<:I
G' Ts: MARf-Rp
"<:I
Tn: E=l
<:,t
"' MARf-WZ i:r:: ...
<:,t
T6: MBRf-[MAR]
~"' i:r::
t'
C '°e, T12:
MBRf-[MAR]
i:'
0 T1: A f-MBR
I Tn:
A f-MBR
£
~
24 INSIGHTS ON Ml _._
CROPRocessoRs
I"
INTRODUCTION
11. STAX RP
..:: T1:
- 13. SHLD 16-bit Address
MAR f- PC ..:::
.l:: ~ T1 : MJ\Rf-PC
0..
i::i:::
.
~~
',:t;:,,,
IJ
T2:
T3:
MBRf-[MAR]
IR f- MBR, PCf-PC + 1
~~
.. IJ
T2 : MBRf-[MAR]
><
CU
IJ
1:1. Unspecified
1 G'
IJ
T3: IR f- MBR, PO--PC + 1
~ 0 T4:
~ T4 : Unspecified
V}
"c- . Ts :
MAR f- Rp i:' u
. Ts: MARf-PC
~ t'], Ca'
C U T6:
i::i::: E ., MBRf-A "'"' T6: MBRf-[MAR]
......
~ ·i:: [MARJ f-MBR
~
;: "<:lt
~ ~
~
T7: ~ ~ T7 : z f- MBR, PC f-PC + 1
~~
;:,,,
T9: MBRf-[MAR] s: T16: [MARJ f-MBR
Q ~ ~ T10: W f- MBR, PC f-PC + 1 14. IN 8-bit Address
~
~
i::i:::
~ T1: MAR f-PC
"c-
~
.
',::
<::t
i::i::: .. Tu : MARf-WZ
"' IJ
"<:lt;:.,,
cu
IJ ..:::
T2: MBR f- [MARJ
i::i::: C' " T12: MBRf-[MAR] "'"' ~~ T3: IR f- MBR, PCf-PC + 1
C cJ'
E Tn: L f-MBR ~
~
~ T4 : Unspecified
~ ~
C'
. cl T14: MARf-WZ + 1
·-....
.Q
00
I
i:'
!~
u"'
C ;:.,,
Ts :
T6:
MAR f-PC
MBR f- [MARJ
-
C
E
cJ' Tis: ~ ~ ~ T7: z f- MBR, PC f-PC + 1
MBRf-[MAR]
~] T16: H f-MBR
'B- ~
R:;
~ ~
·i:: "'
Ts: IOAR f-Z
~
s:], T9 : IOBR f-A
ou T10: A f-lOAR
~
I"
INTRODUCTION
15. OUT 8-bit A ddress
. .
- 19. ADCR
~ T1 :
MAR
MBR
f- PC
f- [MAR]
. T1 : MAR f--PC
"I:$
C U
~..::
;:,-.
T2:
IR f-MBR, PCf-PC+l
~i:::.:::
I=: u
i~
"'..s::
T2 : MBR f--[MAR]
0~
~
T3 :
T4: Unspecified i:::.::: ~ t~ ~
T3:
T4:
IR f-- MBR, PCf--PC+l
Unspecified
::i::
,...
C
h
C'],
. T1 : MAR f-PC 20. ACI 8 -bit Data
:::s
0 C U
¼: T2: MBR f- [MAR] . "' ~ T1: MAR f--PC
~
~
..
~ .
"I:$
i::s
A:.
T3: z f- MBR, PC f-PC + 1
·t
i::s
"I:$
cu
t~. "'..s::
;:,-.
T2:
T3:
MBR f-- [MAR]
IR f-- MBR, PCf--PC+l
i:::.:::
.
.... ~o.... r..., T4: Unspecified
·t
s
~
~
T1:
T2:
!OAR f-Z
IOBR f-A
!,ol · -
h .I;'
i:::.::: 00 C'~
. Ts:
MAR f--PC
au
~ T3: [!OAR] f- IOBR, SC f- 0 u
~
C cJ" T6:
MBR f--[MAR]
~] T7:
A f-- MBR + A + CY, PC
f-PC + 1
16. XCHG i:::.:::
~\.!)
..
"I:$;:.,
C
~
U
T1:
T2 :
MAR f-PC
MBR f-[MAR]
21. ADDM
..s:: T1: MAR ~PC
::i:: ~
~ u "' ..s:: T3: IR
i:::.::: ><
;:,._"'
0 .....
~ T4:
f-MBR, PCf-PC+l
Unspecified ~ . "'
~~
',:s
au
;:,-.
T2:
T3:
MBR
IR
f--[MAR]
f-- MBR, PCf--PC + 1,
17. ADDR
§ T4:
~ <3- Unspecified
. ~
"'
T1: MAR f-PC ~
Ts: MAR f--HL
~
~A:. "I:$;:,.,
CU T2 : MBR <-- [MAR] C'-,:stS ~"'
t:: § 0
t~.:= T3: IR <-- MBR, PCf--PC+l
0
ij "' ;:,-. T6: MBR f- [MAR]
A:. ~
~ T4:
~ i:::.::: u T7: A f--MBR+A
Unspecified
18. ADI 8-bit Data 22. ADCM
16'
. ~
"' T1:
T2:
MAR <-PC ..s::
~
. T1: MAR f--PC
.s "'..s::
MBR <-[MAR] ~~ T2: MBR f-- [MAR]
0i::..."' T3: ~~
~::
i::s IR
.....
~
<-- MBR, PCf--PC+l ~ au T3: IR f-- MBR, PCf--PC + 1,
T4: Unspecified u ~
t::A::.(l()~ ., 0 0 T4: Unspecified
c><3 ~
Ts: MAR
cS ct3'
~
<-PC ~
i:' ~"'
~ T6: Ts: MAR f--HL
MBR
~]Ct:: T7: A
<-[MAR] I=:
i:::.::: Q 0' T6: MBR f--[MAR]
f--MBR + A, PC f--PC+l ~ ',:s
~ ~ T7: A f--MBR+A+CY
i:::.:::
2B \ '""GHT~ROPR
OCESSORS
INTRODUCTION
23. INRM
,.:: T1 : MAR f-PC
....I.) • Industry
~.., ~I.) T2: MBR f- [MARJ
It is used in data monitoring system, autom a tic weigh ting,
"I:!~ T3: IR f- MBR, PCf--PC + 1, batching systems, etc .
oU
I.)
~ • Security systems
0 T4: Unspecified
~ MAR f-HL
It is used in smart cameras, CCTV, smart doors, etc.
Ts :
~ i:' "I:!
E.., ~
..,
C l::t ~ T6: MBR f- [MARJ
•
•
Automatic system
Robotics
"o-- .., ~ u
~ T1: z f-MBR
•
~ Communication system
~
......, • Games machine
·c Ts : MAR f-HL
3: ~ • Accounting system
i:'
ou
~ T9: MBR f-Z+l • Complex industrial controllers
E Tio: [MARJ f-MBR • Data acquisition system
i • Military applications system
30 INSIGHTS ON MICROPR
ESSORS
INTRODUCTION
I,
temporary register is used to hold data during an
arithmetic/logic operation. The result is stored in the
-.... accumulator; the flags (flip-flops) are set or reset according
PROGRAMMING WITH 8085 to the result of the operation.
2. Accumulator (Register A): It is an 8-bit register that is the
MICROPROCESSOR part of ALU. This register is used to store the 8-bit data and
to perform arithmetic and logic operations. 8085
2.1 Internal Architecture of 8085 Microprocessor microprocessor is called accumulator based microprocessor.
When data is read from input port, it is first moved to
The Intel 8085A is a complete 8-bit parallel central
accumulator and when data is sent to output port, it must be
processing unit. The main components of 8085A are array of
first placed in accumulator.
registers, the arithmetic logic unit, the encoder/ decoder, and
timing and control circuits linked by an internal data bus. 3. Temporary Registers (W and Z): They are 8-bit registers not
accessible to the programmer. During program execution,
SIO SOD
8085A places the data into it for a brief period.
4. Instruction Register (IR): It is an 8-bit register not accessible
t~ the programmer. It receives the operation codes of
instruction from internal data bus and passes to the
instruction decoder which decodes so that microprocessor
knows which type of operation is to be performed.
5. Register Array (Scratch Pad Registers B, C, D, E): Each one
(B, C, D, E) is an 8-bit register accessible to the programmers.
Data can be stored upon it during program execution. These
r"c'c--ccc-+-=-=---1 f
i----=--,'-='---.j 1 can be used individually as 8-bit registers or in pair BC, DE
as 16-bit registers. The data can be directly added or
transferred from one to another. Their contents may be
incremented or decremented and combined logically with
the content of the accumulator.
6. Register H & L: They are 8-bit registers that can be used in
same manner as scratch pad registers.
. .,,.... Allr"'I,
Figure2.1:TheBOBSAm' - .... _ _ .._. 7. Stack Pointer (SP): It is a 16-bit register used as a memory
rcraprocessor function,,/ bl k d.
So oc lllgram pointer. It points to a memory location in R/W memory,
urce: lntel Corporation. Embedd rl M
a
e tcroprocessors (Santn
ara Calif: Author 1994), pp 1-11 called the stack. The beginning of the stack is defined by
1. ALU: The arith . loading a 16-bit address in the stack pointer.
. mettc logic unit f
functions. It includ h per orms the computing
· esteaccu I 8. Program Counter (PC): Microprocessor uses the PC register
register, the aritluneti mu ator, the temporary
c and logi · . to sequence the execution of the instructions. The function of
c crrcuits and five flags. The
32 INSIGHTS ON MICROPRocessoRs
PROGRAMMING WITH 8085 MICROPROCESSOR 33
PC is to point to the memory address from which the ne
byte is to be fetched. When a byte is being fetched, the
incremented by one to point to the next memory location.
Pc: WR signals are sync pulses indicating the availability of
data on the data bus.
9. Flags:
D1 11. Interrupt Controls: The various interrupt controls signals
Do
(INTR, RST 5.5, RST 6.5, RST 7.5, and TRAP) are used to
I s I z I X AC X p X I CY] interrupt a microprocessor.
Register consists of five flip flops, each holding the status of 12. Serial J/O Controls: Two serial 1/0 control signals (SID and
different states separately is known as flag register and each SOD) are used to implement the serial data transmission.
flip flop are called flags . 8085A can set or reset one or rnore
Programmer's Model of an 8085 Microprocessor
of the fla~s. The flags are sign (S), Zero (Z), Auxiliary Carry
(AC), Parity (P), and Carry (CY) . The state of flags indicates
the result of arithmetic and logical operations, which in turn
can be used for decision making processes. The different A 8 Flag 8
flags are described as:
B 8 C 8
• Carry: It stores the carry or borrow frorn one byte to
another. . If the last operation generates a carry or D 8 E 8
borrow, its status will be 1 otherwise 0.
• Zero: If the result of last operation is zero, its status will
H 8 L 8
be 1 o~erwise 0. It is often used in loop control and in SP 16
searching for particular data value.
• PC 16
Shignl: If the ~ost significant bit (MSB) of the result of
t e ast operation is 1 ( • Data bus
. O. negative), then its status will be 1 Address bus
o therwise
• ,.
Parity: If the result of the 1
number of 1' ( ast operation has even 8 lines 16 lines
otherwise 0. s even parity), its status will be 1
'✓ ' 7
'
• Auxiliary Carry· If h
· t e last operaf
Bidirectional Unididrectional
from the lower half word (lo i~n generates a carry Figure 2.2 Programmer's model of an 8085 microprocessor
be 1 otherwise o. Wer rubble), its status will
The programmer's model of an 8085 microprocessor consists
10.
Ti_m ing and Control Unit: This . of:
microprocessor operations With thurut synchronizes all the
control signals e clock and Accumulator
. necessary for generates the
microprocessor and peri h conunUnication betwee th It is an 8-bit register accessible to programmer. Almost all
• . P erals. Th n e
sirrular to the sync pul . e control signals are arithmetic, logical, and 1/0 operations are performed on the
se m an oscilloscope Th -R accumulator.
· e D and
34
INSIGHTS ON MICRO
PRocessoRs
• INTR (Input): Interrupt request, used as a g 2.3 Instruction Description and Format
purpose interrupt. enera1
The computer can be used to perform a specific task, only by
specifying the necessary steps to complete the task. The collection
• INTA (Output): This is used to acknowledge an of such ordered steps forms a 'program' of a computer. These
interrupt. ordered steps are known as instructions. Computer instructions are
• RST 7.5, 6.5, 5.5 (Inputs): These are vectored inte stored in central memory locations and are executed sequentially,
rrupts one at a time. The control reads an instruction from a specific
that _transfer the program control to specific memo
address in memory and executes it. It then continues by reading
locations. They have higher priorities than INTry
. R the next instruction in sequence and executes it until the
mterrupt. Among these three, the priority order is 7
completion of the program.
6.5, and 5.5. .5'
H=7A, L=32
88 A
HLT
Using LOA
LDA2050H
HLT
14. SHLD 16-bit Address (Store HL Pair Direct) 2. Register B contains 32H, Use MOV and STAX to copy the
• 1-byte instruction contents of register B in memory location 8000H.
UsingMOV
• It is opposite to LHLD instruction
LXIH, 8000H
• Store_s the contents of L-register to specified memory
location and contents of H-register to next higher MOVM,B
memory location. HLT
E.g., LXI H, 9500H UsingSTAX
SHLD 8500H; (8500] = 00, (850{] = 95 LXI D,8000H
15. XCHG (Exchange)
MOVA, B
• 1-byte instruction
STAXD
• Exchanges DE pair with HL pair.
.
HLT
E.g., LXI H, 7500H; H= 75, L=00
3. The accumulator contains F2H, Copy A into memory
LXI D, 9532H; D=95. E=32 8000H. Also copy F2H directly into 8000H.
XCHG;
Examples H= 9s, L=32; D=75, E=OO STA8000H
LXIH, 8000H
1. !he memory location 20SOH
instructions to trans{ th holds the data byte F7H. Write MVIM,F2H
diff er e data b t
erent op-codes: Moy L Y e to accumulator using
Using MQy ' DAX and LDA.
HLT
4. The data 20H and 30H are stored in 2050H and 2051H.
LXI H,2050H
WAP to transfer the data to 3000H and 3001H using LHLD
and SHLD instructions.
44
- - ------
r
MICROPROCEss~- - -
PROGRAMMING WITH 8085 MICROPROCESSOR
MOVA, L
ADDC Features of Arithmetic Instructions
DAA The arithmetic operations, add and subtract are performed
in relation to the contents of accumulator. The features of these
MOVC,A
instructions are:
MOVA, H
1. They assume implicitly that the accumulator is one of the
ADCB operands.
DAA 2. They modify all the flags according to the data conditions of
the result.
MOVB,A
3. They place the result in the accumulator.
HLT
2. 4. They do not affect the contents of operand register or
Register BC contain 2793H and register DE contain 3182H memory.
Write instruction to add these two 16 bit numbers and
place the sum in memory locations 2050H and 2051H. But the INR and DCR operations can be performed in any
register or memory. These instructions
MOVA,C
1. affect the contents of specified register or memory.
ADDE
2. affect the flag except carry flag.
MOVL,A
MOVA,B Addition Operation in 8085
ADCD 8085 performs addition with 8-bit binary numbers and stores
MOVH,A the result in accumulator. If the sum is greater than 8-bits (FFH), it
sets the carry flag.
SHLD2050H E.g. MVI A, 93H B7H: 1011 0111
HLT MVIC,B7H
ADDC + 93H: "'"l-'-0"""'0_1_0'-0-'--1_1
3. R . [D 4A [DO 1 00 l O 1 0
egister BC contains 8538H
62ASH. Write instru ti and register DE contain CY 4AH---~
CY'--
from the contents of ;Cons to subtract the contents of DE
MOV A, C and place the result in BC. Subtraction Operation in 8085
SUBE 8085 performs subtraction operation by using 2' s
complement and the steps used are:
MOVC,A
1. Converts the subtrahend (the number to be subtracted) into
MOVA,B
its l's complement.
SBBD
2. Adds 1 to 1's complement to obtain 2' s complement of the
MOVB,A subtrahend.
HLT 3. Adds 2' s complement to the minuend (the contents of the
accumulator).
I"
PROGRAMMING WITH 8085 MICROPROCESSOR
• CY and AC are reset and others as per result.
E.g.,ORAC;A+-A 11 C CPI 8-bit Data (Compare Immediate with Accumulator)
§-LiD±f f f ff f)J •
•
1-byte instruction
It complements the content of accumulator.
RAR (Rotate Accumulator Right throu gh Carry) Data Masking (Setting and Resetting Specific Bits)
• 1-byte instruction In various situations, we need to set or reset a specific bit
without affecting the other bits. This process is referred to as data
• Each bit is shifted right to the adjacent position. Bit Do masking.
becomes the carry bit and the carry bit is shifted into Di.
Setting bits
• The carry flag is modified according to Do.
Logical OR instructions are used to set particular bits
LiiH-°¥ff ff f +\J
without affecting other bits. This is done by ORing the particular
bits with logic 1 and other bits with logic 0. This is known as OR
masking.
CY= Do' Do= D1, ........ D7 = CY
For example, if the accumulator has data 1100 1000 = C8H
The rotate instructions
divide operations and f are ~sed in arithmetic multiply and • By ORing C8H with 03H (0000 0011) using instruction
or senal data transfer. ORI 03H, accumulator will have 1100 1011 = CBH, that
For example, if the ace
• umulator has data 00001000 = 8 is, Do and D1 of accumulator are both set to 1, and other
By rotating 08H left bits are unchanged.
0000 = 16 whi h . , accumulator will have 0001
c is equivale t t Resetting bits
• B .
y rotating 08H ri t
n °multiplying by 2.
0100 = 4 hi . gh , accumulator will h OOOo Logical AND instructions are used to reset particular bits
w ch 1s equ· al ave without affecting other bits. This is done by ANDing the particular
However, these . iv ent to dividing by 2.
D, to D0 are invalid When 1 . bits with logic O and other bits with logic 1. This is known as AND
and rotated right fr ogic 1 is rotate d left from masking.
om Doto D7.
56 INSIGHTS For example, if the accumulator has data 11001000 = CBH
ON IIIIICROPRocesso-~RS_ __
PROGRAMMING WITH 8085 MICROPROCESSOR 57
By ANDing C8H with 3FH (0011 1111) Usii)
instruction ANI 3FH, accumulator will have OOOQ ~
10 LDAC020H
= OSH that is D7 and D6 of accumulator are both
, , reset RLC
to 0, and other bits are unchanged.
RLC
Complementing bits RLC
Logical XOR instructions are used to complement particul RLC
bits without affecting other bits. This is done by XORing t: STAC020H
particular bits with logic 1 and other bits with logic 0. This is' HLT
known as XOR masking.
4. Register C contains 95H. Write instructions to unpack
For example, if the accumulator has data 1100 1000 = C8H this data to 09H and 05H, and store into memory
locations 9050H and 9051H.
• By XORing C8H with OCH (0000 1100) using instruction
MVIC,95H
XRI OCH, accumulator will have 1100 0100 = C4H, that
MOVA,C ;Af--95H
is, 03 is complemented to 0 and D2 is complemented to
1, and other bits are unchanged. ANIF0H ; A f--90l-I
Examples RLC
1. Write a program to AND the content of memory location
RLC
COSOH and the content of register C, and store the result RLC
into location COSIH. RLC ; A f--09H
LDAC0S0H STA9050H
ANAC MOVA,C ;Af--95H
STAC0SlH ANI0FH ; A f--05H
HLT STA9051H
2. Write a program to 1 HLT
. . comp ement the content of register D
using instructions XRI and CMA. 5. Register B contains A6H. Write instructions to set D 6 and
Usin~ XRI to reset D2.
MOV A, D Using Masking
XRIFFH
MVIB,A6H
HLT
MOVA,B
Usin~CMA
ORI40H ; Sets D6 [OR 0100 0000 : A f-- 1110 0110]
MOVA, D
CMA ANI FBH ; Resets D2 [AND 11111011: A~ 1110 0010]
HLT MOVB,A
3. Write a program t h
HLT
o c ange th 1
the data stored in Joe ti e ower and upper nibble of
a onco20R.
S588T-;,;NS~IG;;;H~T;;S-;:
O-;::
N-M-IC_R_O_PR- - - -----------
0CESSORS
PROGRAMMING WITH 8085 MICROPROCESSOR 59
Using Rotation
1. Jump Instructions
MVI B, A6H
MOVA,B ; CY r X, Ar 1010 0110 The jump instructions specify the memory location
; CY r 1, A r 0100 110x explicitly. They are 3-byte instructions, one byte for the
RAL operation code follow ed by a 2-byte (16-bits) memory
RAL ; CY r O, A r 1001 lOxl
address. Jump instructions can be used to create loops and
STC ;CYrl are classified into unconditional and conditional jump.
60
INSIGHTS ON MICROPROCESSORS
PROGRAMMING WITH 8085 MICROPROCESSOR 61
Using Label Examples
MVIA,00H 1. WAP to move 10 by tes of data from starting address
Ll: OUT40H 9500 H to 9600H.
!NRA 9500H~=====~~t====:{_-=--=--=--=--=--=--=i9600H
JMPL1
HLT
Using Name
MVIA,00H 9509H 9609H
NEXT: OUT 40H MVIB,0AH
INRA LXIH,9500H
JMPNEXT LXID,9600H
I
66 INSIGHTS ON 0018H
MICROPROCESSORS
PROGRAMIIING vmtl 8085 ""'ROPROCESSOR &7
decremented by one and content of low order re .
.
copied into that location. 8Istet .~
DI - disable interrupt
POP Rp /PSW (Retrieve Register Pair from Stack) El - enable interrupt
10 PUSHD
1997 10
PUSHPSW
20
1998 20
POPH
X
1999 X POPB
POPD
H POPPSW
20 1O L
HLT
Before PUSH
SP::1999
H=93 L= 20
Some Other Instru ti
c ons C=32
B=47
X1BL - exchanges to O
f
stack (TOS) With BL
SPHL _ move HL to Sp
p D=AB E=CD
----.--P_CHL - move HL to PC A=34 F= lO
68
INSIGHTS ON MICROPRocessoRs
PROGRAMMING WITH 8085 MICROPROCESSOR
After POP
H = 34 L=lO 1. Direct Addressing Mode:The instruction using this mode
C=CD specifies the effectiv e address as part of instruction. The
B=AB
instruction size is either 2-bytes or 3-bytes with first byte op-
D= 47 E=32 code followed by 1 or 2 bytes of address of data. Some
A =93 F=20 examples are:
LDA9500H
Note: STACK· works in LIFO (Last In First Out) m anner.
SHLDCOS0H
2. Write a program to set carry flag, reset sign fla IN80H
other flags as it is. g and keep
This type of addressing is also called absolute addressing.
LXI SP, CFFFH
2. Register Direct Addressing Mode: This mode specifies the
PUSHPSW ; Push flag into stack register or register pair that contains the data rather than
POPH address. That means the operand is in general purpose
; Retrieve flag into L recnster
o~
[HL t-A+F]
register. Some examples are:
MOV A,L
MOVA, B
ORI01H ; Set carry flag
ADDD
ANI7FH ; Reset sign flag
ORAC
MOVL,A
XCHG
PUSHH
; Push HL into stack Register · Indirect Addressing Mode: In this mode, the
3.
POPPSW operand part of the instruction specifies the register pair
; Retrieve
. upda t e d fl ag into
. flag register
HLT whose contents are the address of the operand. That means
the address of operand is specified by a register pair. So, in
2.5 Addressing Modes this type of addressing mode, it is the address of the address
Instructions are rather than address itself. Some examples are:
micropr ocessor. The instr command
. to p erform a certain task in
STAXB
[data or address] Th uction consists of op d d
onl · e•operand b -co e and operan LDAXD
reJst:: !oth of them. In thesen:~ t~e source only, destination MOVA,M
recnste/ amemory, or an input port s ·milc_ons, the source can be a
o· , memory I · 1 arl d 4. Immediate Addressing Mode: In this mode, the operand
which th dd ocation, or an Y, estination can be a position is the immediate data. That means, the operand is
ea ress of output
result is given in so~rce of data or the port. The methods by specified within the instruction itself. For 8-bit data,
other words th th e Instruction ar address of destination of
' e Vario f e called dd instruction size is 2 bytes and for 16-bit data, instruction size
are called addr . us ormats (way ) a ressing modes. In is 3 bytes. Some examples are:
th essmg mod s of spe uy·
e operands are es. So, addre . c mg the operands
1 MVIA,32H
addressing mod ocated rather than ths~mg mode specifies where
es. eu nat LXI B, 4567H
70 ure. The 8085 has five
INSIGHTS ON M
ICROPROcEssoRS
PROGRAMMING WITH 8085 MICROPROCESSOR 71
SUI95H
XRI55H conditions are satisfied. These loops usu ally include
5. Implied or Inherent Addressing Mode: The m
· ..__ counting and indexing.
S., ~Cti
0
this mode do not have operands. If address of s 0 11s . The looping in 8085 microprocessor is performed by
urce '
as well as address of destination of result is fixed of d,~ following steps:
· d · ,then ,l1
1s no nee to give any operand along with the ins " !11 • Counter is set up by loading an appropriate cou nt in a
Some examples are: trucn0~
register.
NOP • Counting is performed by either incrementing or
HLT decrementing the counter.
Time Delay
2 ·6 Time Delay and Counter
When we use loop by counter, the loop causes the delay.
Counter Depending upon the clock period of the system, the time delay
occurs during looping. The instructions within the loop use their
It is designed simply by loadin an a .
one of the registers and . th g ppropnate number into own T-states. So, they need certain time to execute resulting delay.
. using e INR or OCR . tru .
1s established to updat ms ctions. A loop Suppose, we have an 8085 microprocessor with 2 MHz clock
e a count and each ·
d etennine whether i·t h h , count is checked to frequency.
as reac ed th f al
is repeated. e m number, if not the loop
Clock frequency of system (f) = 2 MHz
Loop 1 1
Clock period (T) = f = 2 xlQ--6 = 0.5 µs
. The programming techni
~croprocessor to repeat t ks . que used to instruct the
instructing th . as 1s called lo · Time delay example:
;n d e rrucroprocessor t0 h oping. A loop is set by
p~rform the task again Th. c ange the sequence of execution
ump instructions. . Is process is accomplished by using
Instructions T-Sates
MVIC,FFH 7
Loops can be classified . LOOP: DCRC 4
mto two t .
• Continuous loop ca egones:
JNZLOOP 10/7
It is set up by .
progr usmg the uncond · · Here, register C is loaded with count FFH (25510) by using
tasks am _With a continuous loo Itional Jump instruction. A MVI which takes 7 I-states. Time to execute. MVI instruction
until the system is reset p does not stop repeating the (outside loop)= 7 T-states x 0.5 = 3.5 µs
• Conditional loop .
Next, 2 instructions DCR and JNZ form a loop with a total of
It is set up b .
. Yusmgth 14 ( = 4+10) T-states. The loop is repeated 255 times until C=0. The
mstructions h e conditional J
---,.__ c eek flags and re ump instructions. These time delay in loop (TC) with 2 MHz frequency is
72 1NSIGHrs ON Mtc
peat the ..
specified tasks if the
I"
ROPRocessoRs PROGRAMMING WITH 8085 MICROPROCESSOR
T1 = ( T x I-states of loop x count)
ANI0FH MVIB,0AH
ADDC CALLBINBCD
STA2030H MOVM,A
HLT RET
BINBCD:
2.7.2 Binary to BCD Conversion
MVIM,FFH
If we need to convert a b. . .
BCD number, followin t mary number mto its equivalent NEXT:
g s eps can be sought·
Step 1· If b. · INRM
· mary number < 100 (64H), goo t step 2
Else subtract 100 (64H) .. SUBB
. repetitively.
Quotient is BCD1 (Divide by 100) JNCNEXT
Step 2: If
remainder from step 1 < 10 0 ADDB
Else subtract (0 ( AH), goto step 3
. 10 AH) repetitive! INXH
Quotient is BCD (D' . y. RET
Step 3: Rema. 2 IVIde by 10)
mder from step 2 is BCD 2.7.3 Binary to ASCII Conversion
E.g., 111111112 (FFH - 3 .
Example ) - 25510"' 0010 0101 0101aco A computer is a binary machine, to communicate with the
l. Ab' computer in alphanumeric letters and decimal numbers,
inary numb translation codes are necessary. The commonly used code is
memory 1 . er (Suppose FFH
and stor ocatton 2020}! Co : llll 11112) is stored ill known as ASCII (American Standard Codes for Information
e each BCD . nvert the CV
memory loca . as two number into B Interchange). It is a 7-bit code with 128 combinations and each
tion from 2030H unpacked BCD digits ill combination from 0lH to 7FH is organized to a letter, decimal
INSIGHTS ON M .
ICROPRocessoRs
PROGRAMMING WITH 8085 MICROPROCESSOR 77
number, symbol or machine command. For example,
30
represents 0 to 9, 41H to SAH represents A to z, lf-iIi to 3~,
,~
2
represents various symbols, and 61H to 7AH represent to ~ CALL ASCII
s a to
General Letters /Numbers ASCII (Hex) ASCII (D . z. STAXD
ec11nill)
0-9 30-39 HLT
48-57
A-Z 41 - SA ASCII: CPI 0AH
65-90
JC BELOW
a-z 61-7A 97 -122 ADI07H
The following simple algorithm can be implem
BELOW: ADI 30H
need to convert 8-bit binary number to ASCII ented if II",
RET
If number < 10, then add 30H
Else add 37H (30H + 07H) 2. 7 .4 ASCII to Binary Conversion
For example: A= A+ 30H + 07H = 41H The following algorithm can be implemented for converting
Example
a number from ASCII to 8-bit binary.
Step 1: Subtract 30H
1. An 8-bit binary number is stored in memo . I .
Step 2: If < 0AH, then binary as it is
1120H. WAP to store the ASCII d _ry ocation
• . • co es of the binary di 'b Else subtract 07H
m 1ocation 1160H and 1161H. gi
E.g., if ASCII is 41H, then 41H - 30H = llH; llH - 07H =
LXI SP, 1999H 0AH
LXI H, 1120H ; Source Example
1. WAP to convert ASCII code stored at memory location
LXI D, 1160H ; Destination
1040H to binary equivalent and store the result at location
MOVA,M 1050H. LXI SP, 1999H
ANIF0H LXI H, 1040H; Source
RRC LXI D, 1050H; Destination
RRc MOVA,M
RRc CALLASCBIN
RRc STAXD
CALLAScu HLT
STAXo ASCBIN: SUI 30H
INXH CPI0AH
M:ov A,M: RC
•
ANI OFH SUI07H
INSIGHTS ON RET
MICROPRocessoRs
PROGRAMMING WITH 8085 MICROPROCESSOR 79
z.7.5 BCD to 7-Segment LED Code Conversion
Each segment in a seven-segment display is identif
. h .. . . t· led bs number and select an appropriate seven segment code for
an index from O to 6, with t e positions given m 1gure. For ,, each digit. Th e cod es should be stored in output buffer
conversion, table lookup technique (TL T) is used. In TLT, the coct this memory.
digits to be displayed are stored sequentially in memory so es of LXI SP, 1999H
these codes can be used effectively and efficiently. tha1
LXI H, 1150H
0 MVID,03H
LXI B, 1190H
NEXT: MOVA, M
ANIFOH
RRC
RRC
RRC
RRC
t;
locations t . ed BCD numb
digits 0 arting at 1150H. The ers are stored in memor)'
memory I 9 for a common thseven segment codes of
STAXB
POPH
memory isocatton
r 8 . at ca ode LED are stored ill
starting ·
117011 RET
eserved at 1190H W and the output buffet
INSIGt-trs ON • AP to unpack the BCV
MICROPRocessoRs
PROGRAMMING WITH 8085 MICROPROCESSOR 81
2 _8 Multiplication and Division
Multiplication
Example
Multiplicatwn can be performed by repeated addi .
However it is inefficient technique for a large multiplier. A. tio~ 1. Write a program to divide 16-bit number stored in memory
locations 8800H and 8801H by the 8-bit number stored at
efficient technique can be devised ·by following the ~ 011
memory location 8802H. Store the quotient in memory
multiplication of decimal numbers. Each bit of multiplier is t ~~
.. aken locations 8900H and 8901H and remainder in memory
one-by-one and it is chec kd e w hh et er It IS 1 or 0. If the bit locations 8902H and 8903H.
multiplier is 1, the multiplicand is added to the product anct of
product is shifted to left. When the bit of multiplier is o, ~
I
LHLD8800H ; Dividend in HL
product is simply shifted to left by one bit.
LDA8802H
Example MOVC,A ; Divisor in C
1. Write a program to multiply two 8-bit numbers stored a LXID,OO00H ; Quotient = 0
COSOH where multiplicand at C0S0H and multiplier a:
NEXT: MOVA, L
C051H; store 16-bit result at memory location C052H.
SUBC ; Subtract divisor
MVID,00H MOVL,A ; Save partial result
LDAC0S0H JNCSKIP ; ifCYljump
MOVE,A ; Multiplicand in DE DCR H ; Subtract borrow of previous subtraction
LOA C051H ; Multiplier in A SKIP: INXD ; Increment quotient
LXIH,00OOH
MVIC,08H ' ; Counter MOVA,H
LOOPl:DADH CPI OOH ; Check if dividend < divisor
RAL ; Left shift partial product by 1 bit
; Rotate multiplier by 1 bit JNZNEXT ; if no repeat
JNCNExr
MOVA,L
DADD · Prod -
NEXT: DCR c ' uct - Product + Multiplicand CMPC
JNZLOOPt JNCNEXT
SHLDC052H
HLT SHLD8902H ; Store the remainder
Division
XCHG
Division can be SHLD8900H ; Store the quotient
d· · · performed b
IVISor is s~b_tracted from the di . y repetitive subtraction. The HLT
~han the divisor. After s V1dend until dividend will be less
mcremented by 1. Fin I uccessful subtraction ti. t 'II be
remainder a Value of muI . . ' quo en W1
· tiplicand registers will be the
82
I"
INSIGHTS ON 1111
ICROPRocEssoRs
PIIOGRAMIING WITH BOBS MK:ROPROCESSOR
1. Write a program for 8085 to change the bit => LXI H, 9000H ;Let 16 bit number starts from 9000H
0
numbers stored at address 7600H if the number 5 of le1 MVI C, 09H ;set counter
s are I
than or equal to 80H. [2061 A h . ilrg~ MVI B, OOH ;to save carry over 16 bits
s Wzn]
⇒ LXIH, 7600H MOV E, M ;get LS byte of 16 bits data to E
IN X H ;increment the memory pointer
MVI C,0AH ;COUNTER MOV D, M ;get MS byte of the 16 bit data to D
LOOPl: MOVA,M ; A<-[H L] REPEAT: INX H ;increment the memory pointer
CPI80H MOV A,M ;get LS Byte of NEXT data to A
ADD E ;add it with PREVIOUS data in E
JC NEXT DAA
XRI20H MOVE,A
MOVM,A INXH ;increment the memory pointer
NEXT: MOVA,M ;get MS Byte of NEXT data to A
INXH
ADCD ;add it with PREVIOUS data in D
DCR C DAA
JNZLOOPl MOVD,A
HLT JNCPASS
2. MOVA,B
Registers BC contain 2793H . ADI0lH
3182H. Write instru ti and registers DE contain ;incremen t the carry by 1
and place the sum t ons to add these two 16 bit numbers
n memory location s 2050H and 2051H. PASS:
DAA
DCR C ;update counter
JNZ REPEAT ;continue for 10 w ords
⇒ [2062 Baishakh]
LXIB, 2793H INX H ;24 bit results in B, D, E respectiv ely
LXID,3I82H MOV M,E ;storing final 24 bit sum at end of
MOVA,C ;table
ADDE INXH
MOVM,D
MOVL,A
INXH
MOVA,B
MOVM,B
ADco HLT
MOVH,A 4. Write a program for 8085 to convert and copy the lowercase
SHLD2osoH ASCII codes to uppercase from memory location 9050H if
HLT any, otherwise copy as they are. Assume there are fifty
3. Write a program f codes in the source memory. [Note: ASCII Code for
and store 24-b. or 8085 to add t A=65 ....Z=90, a=97 ....z=122] [2062 Bhadra]
numbers. it Ben result at th:n 16-bit PCD numbers
end of the ten given LXI H, 9050H ; loads memory in HL
[2062 Bhadra] MVIC,32H ; counter for 50 codes.
JMPBELOW BELOW:INXH
SWAP: MOV B, A DCRC
AN144H JNZNEXT
; A-an bits zero except
;D6&D2 HLT
CPI 44H
; 0 6& D2both are 1 14. Write a program in 8085 to transfer 8-bit number from one
JZBELOW table to other by setting bit Ds if the number is less than
; no need to swap
CPI OOH 80H else transfer the number by resetting bit D6,
; 0 6& 0 2both are O
JZBELOW [2068 Bhadra]
; no need to swap
MOVA,B ⇒ Suppose first table is having ten 8-bit numbers starting from
XRI44H A000H and second table starting from A030H.
BELOW: ST AX D LXI H, A000H ; source
INXD LXI D, A030H ; destination
INXH MVIC,0AH ; counter
DCRc NEXT: MOVA, M
JNZNEXT
CPI80H
HLT
13. JC BELOW ; if number < 80H
Ten no. of 8-bit
a pro data is started .
t bl gram for 8085 m. in mem ory at AOOOH. Wri~ ANIBFH ; resets D6
a e at A03Q}i icroproces "'
24}i if the data • sor to copy the data to n,,. JMPSTORE
. 1
is ess th
an 70H and greater tbaJI
BELOW: ORI20H ; sets Ds
INSIGHTS ON [2068 Magh]
MICROPRocEssoRs
PROGRAMMING WITH 8085 MICROPROCESSOR 93
STORE: STAX D
INXH
INXD RRC
RRC
DCRC RRC
JNZNEXT RRC
MOVB,A ; u pper nibble
HLT MOVA,M
15. Write an assembly language program for 8085 to exch ANI0FH ; lower nibble
the bits D6 and 02 of every byte of a program. Su an~ ADDB
there are 200 bytes in the program starting from m:;:11 STAXD
INXH
location 8090H. [2070 Bhadra] q
INXD
⇒
LXI H,8090H; source DCRC
MVI C, C8H ; counter 200 JNZNEXT
NEXT: MOVA,M HLT
ANI44H
17. Write a program in 8085 to calculate the n umber of on es in
CPI 44H .: check if both bits are 1
JZNOSWAP the upper nibble of ten 8-bit numbers stored in tabl e. Store
the count of ones in a location just after the table.
CPI OOH ; check if both bits are O
JZNOSWAP [2072 Ashwin]
DCRc 21. Write a program for 8085 to count the numbers for which ·
JNZNEXT upper nibble is higher than the lower nibble; and store the
HLT count at the end of table having 50 bytes data from C050H.
[2075 Bhadra]
=-=-~
value in the IP indicates the address of an instruction to be fetched
for execution.
Data segment register: Data segment contains the starting
, - - - - -- - . I address of a program's data segment. Instructions use this address
I to locate data. This address plus an offset value in an instruction,
causes a reference to a specific byte location in the data segment.
Stack segment (SS) register and stack pointer (SP): Stack
segment contains the starting address of a program's stack
segment. This segment address plus an offset value in the stack
pointer indicates the current word in the stack being addressed.
Extra Segment (ES) register: It is used by some string
(character data) to handle memory addressing. The string
6. z (zero flag): This flag is set when the result of the 3 .2.2 Segment and Offset Address
computation is or comparison performed by the previous Segments are special areas defined in a program for
instruction is zero. 1 for zero result, 0 for nonzero result containing the code, data, and stack. A segment begins on a
7. A (auxiliary carry): This is set if there is a carry from the paragraph boundary. A segment register is of 16 bits in size and
contains the starting address of a segment.
lowest nibble during the addition or borrow from the lowest
nibble during subtraction. A segment begins on a paragraph boundary, which is an
8. P (parity flag): This flag is set to 1 if the lower byte of the
address divisible by decimal 16 or hex 10. Consider a DS that
result contains even number of l's otherwise reset. begins at location 038E0H. In all cases, the rightmost hex digit is
zero, the computer designers decided that it would be unnecessary
9. C (carry flag): This flag is set when there is a carry out of to store the zero digit in the segment register. Thus 038E0H is
MSB in case of addition or a borrow in case of subtraction. stored in register as 038EH.
3.2.1 Features of8086 Microprocessor The distance in bytes from the segment address to another
Intel 8086 is a widely used 16-bit microprocessor. The location within the segment is expressed as an offset or displacement.
features of 8086 microprocessor can be su1r..marized as follows: Suppose the offset value is 0032H for above example of data
1.
segment. The effective address or an actual logical memory
The 8086 can directly address 1MB of memory.
location addressed by an instruction is the sum of the segment
2. address and the offset address. Hence, we can generate the 20-bit
The internal architecture of the 8086 microprocessor is an
example of register-based microprocessor and it uses physical address by using the expression that follows.
segmented memory.
SA: OA (segment address: offset address)
3.
It pre-fetches up to 6 instruction bytes from the memory and 038EH : 0032H = 038EH x 10H + 0032H
5J_ueues them in order to speed up the iristruction execution.
4. = 038E0H + 0032H = 03912H
It_ has d~ta bus of width 16 bits and address bus of width 20
bits. So 1t always accesses a 16_b·t Therefore, physical address = 03912H
1 wor d to or from memory.
5. Programmer's Model of an 8086 Microprocessor
The 8086 microprocessor is divided internally into two
separate uruts which are bus interface uru't (BIU) d th Figure 3.2 illustrates the programmer's model of an 8086
execution unit (EU). . an e microprocessor.
6. The BIU fetches instructi ·
results. ons, reads operands, and writes
7. The EU executes instru t·
c 10ns that h
by BIU so that instru ti ave already been fetched
. k c ons fetch overla .h .
w hi ch IS nown as pipelin. ps wit execution
mg.
E;8
AH AX AL Accumulator
l11StnK,1.1on Po,~
1oa I
1NS1GHTS 0111 MIClllai..,
--
E.g., XCHG AX, BX DIV (Divi Ion)
g.
XCHGAL, BL
- DIV Re ⇒ AX/Ki, (Remaind\!r -.. AH) and
XCHG CL, [BX) (Quotient AL)
IN AL, DX ; DX: l'ort .uidr , AH al o in AL - DIV R16 ⇒ DX:AX/R 1i, (Remainder --. DX) and
OUT DX, AL/ Al I (Quotient AX)
r
RCL (Ro tate left through carry)
Flag Operation
RCR (Rotate right through carry) •• _CLC (clear carry flag)
E.g., ROL AX, 1 ; rotate by 1 _CLD (clear direction flag)
ROL AX, CL ; if we need to rotate more than one bit
_CLI (clear interrupt flag)
RCLCX, 1
_STC (set carry flag)
RCL [BX], CL ; Only CL can be used
_STD (set direction flag)
c. Shifting
- STI (set interrupt flag
- SHL/SHR/SAL/SAR reg/ mem, 1/ CL
_ CMC (complement carry flag)
SHL (Logical shift left)
SHR (logical shift right)
_LAHF (load AH from flags (lower byte))
-Shifts bzt in true direction and fills zero in vacant place - SAHF (store AH to flags)
SAL (Arithmetic shift left) - PUSHF (push flags into stack)
SAR (Arithmetic shift right) - POPF (pop flags off stack)
-Shifts bit/word in true direction, in former case place zero in s. ST ACK Operations
vacant place and in later case place previous sign in vacant
place. -PUSHreg16
E.g., SHL AX, 1 ; rotate by 1 - POPreg16
SHLAX,CL ; if we need to rotate more than one ilit 6. Looping Instruction
SAR DX, 1 CX is automatically used as a counter.
SAR [BX], CL ; Only CL can be used - LOOP (loop until complete)
d. Comparison
- LOOPE (loop while equal)
- CMP reg/ mem, reg/ mem/ immediate
- LOOPZ (loop while zero)
CMP (Compare)
- LOOPNE (loop while not equal)
E.g., CMP BH, AL
Operandl Operand2 - LOOPNZ (loop while not zero)
CF SF ZF
7. Branching Instruction
> 0 0 0
- 0 0 1
a. Conditional
< 1 - JA Gump if above)
1 0
TEST. test bits (using AND operation) - JAE Gump if above/ equal)
TEST reg/ mem, reg/ mem/ ~ediate - JB Gump if below)
- JBE Gump if below/ equal)
0;.RS;-------------
1'11ioo~1.;;•Niss1iGGiHH,:;rs~o01NNMM1KIC:RRooPiPR"oicciEss;;;
PROGRAMMING WITH 8086 MICROPROCESSOR 111
- JC Gump if carry) String Instructions
9.
_JNC Gump if no carry) _ MOVS/MOVSB/MOVSW ; Move string
_JE Gump if equal) DS: SI (source)
_JNE Gump if no equal) DS: DI (destination)
- JZ Gump if zero) CX (string length)
- JNZ Gump if no zero) -CMPS/ CMPSB/CMPW ; Compare string
- JG Gump if greater~ _ LOOS /LODSB/LODW ; Load string
- JNG Gump if no greater) -REP ; Repeat string
- JL Gump if less)
J.4 Operators in 8086
- JNL Gump if no less)
An operator provides a facility for changing or analyzing
- JO Gump if overflow)
operands during an assembly. Operators are active during
- JS Gump if sign) assembling but no machine language code will be generated.
- JNS Gump if no sign) Operators are divided into various categories:
-JNP Gump if no parity) These operators include the familiar arithmetic signs
and perform arithmetic during an assembly. These
- JPO Gump if parity odd) operators are:
b. Unconditional
+ (addition), + (positive), - (subtraction), - (negation),*
- CALL (call a procedure) (multiplication), / (division), and % (remainder).
- INT (interrupt) ii. Index Operators
- JMP (unconditional jump) For indirect addressing of memory, an operand
- RETN/RETF (return near/far) references a base or index register, constants, offset
variables, and variables. The index operator uses square
- RET (return)
brackets.
- IRET (interrupt return)
8. MOV AX, [SI]
Type Conversion
iii. . Logical Operators
- CBW (convert byte to word)
The logical operators process the bits in an expression.
- CWD (convert word to do bl .
u eword) The logical operators are:
AND, OR, XOR, NOT
1<11i2211.;;1Niss1iGGiHH;Ts;co;;N;iMM1C1ciRooiP~RicoiccEessiSo~RS;;-------------
PROGRAMMING WITH 8086 MICROPROCESSOR 113
TYPE - returns the number of bytes defined for reference
iv. Shift Operators
The shift operators shift an expression during an variable.
assembly. The shift operators are: LENGTH - returns the number of entries defined by a DUP
operator.
SHR, SHL
SIZE - returns the product of LENGTH times TYPE. THIS _
2. Macro Operators creates an operand with segment and offset values that are
A macro is an instruction sequence that appears repeated! equal to those of current location counter.
in a program assigned with a specific name. Y
Basic format of a macro definition: 3,5 Coding in Assembly Language
Macroname MACRO [parameter-list] ; Define mac-;; The assembly language programming needs good
[instructions] ; Body of macro knowledge of machine architectur_e, operating system, and
ENDM ; End of macro programming principles. Assembly language is case insensitive,
3. Record Operators therefore, program can be coded either in uppercase or lowercase
The record operators are: or combination of both. The programs written in assembly
language are compact and efficient, which has to be converted to
~ SK - r e ~ a mask of 1-bits representing the specified machine code for execution and it is performed by the translator
field, and defmes the bit positions that
. the field occup·e
1 ~
known as assembler.
WIDTH - returns a width as the number of bits in a
RECORD. Advantages of assembly language programming:
4. Relational Operators • They generate small and compact execution module.
The relational operators are: • They have more control over hardware.
EQU, GE, GT, LE, LT, NE • They generate executable module and run faster.
5. Segment Operators Disadvantages of assembly language programming:
They are: • Machine dependent
OFFSET, SEC, segment override • Lengthy code
6. Type (or Attribute) Operators • Error prone (likely to generate errors).
They are:
Assembly Language Features
l-ilGH - returns high b t
returns high word of y e of ~ expression. HIGHWORD - The main features of ALP are program comments, reserved
an expression. words, identifiers, statements, and directives which provide the
LOW - returns low byte of an expression
basic rules and framework for the language.
LOWWORD - returns low word of an ex. .
P1R - used on d t . press1on. Program comments:
a a variables and . tr The use of comments throughout a program can improve its
- modifies the NEAR ttr"b mS uctions levels. SHORT
+127 and -128 bytes. a i ute of a JMP destination that is clarity. It starts with semicolon(;) and terminates with a new line.
E.g., ADD AX, BX ; Adds AX & BX
INSIGHTS ON MICROPR
ESSORS
115
114 \ PROGRAMMING WITH 8086 MICROPROCESSOR
'fhese statements, called directives act only during the assembly of
rogratn and generate no machine-executable code. The different
Reserved words:
Certain names in assembly language are reserved for the· ~es of directives are:
own purposes, to be used only under special conditions. Reserve: The Page and Title Listing Directives:
1.
words include: The page and title directives help to control the format of a
Instructions: Such as MOV and ADD (operations to execute) listing of an assembled program. This is their only purpose,
• and they ~ave no effect on subsequent execution of the
Directives: Such as END, SEGMENT (information to the
• program.
assembler)
The page directive defines the maximum number of lines to
Operators: Such as FAR, SIZE (used in expressions)
• list on a page and the maximum number of characters on a
Predefined symbols: such as @DATA, MODEL (returns
@
• information to the program during assembly)
line. Its format is:
PAGE [Length] [,Width]
Identifiers: For example, PAGE 60, 132 means length of is 60 lines per
An identifier (or symbol) is a name that applies to an item in page and width is 132 characters per line. The default value
the program that expects to reference. The two types of identifiers is Page 50, 80.
are name and label. The TITLE directive gives title for a program to print on line
Name refers to the address of a data item such as NUMl DB 2 of each page of the program listing. Its format is:
5. Label refers to the address of an instructi·on, proce d ure, or
segment such as MAIN and Ll : in the following statements. TITLE text [comment]
MAIN PROC FAR 2. SEGMENT Directive
Ll: ADD BL, 73 The SEGMENT directive defines the start of a segment such
as stack, data, and code. Its format is:
Statements:
Segment-name Segment [align] [combine] ['class']
An assembly language program consists of a set of
statements. The two types of statements are:
• Instructions such as MOV and ADD
Segment-name ENDS
• Directives such as COUNT DB 1 Segment name must be present, must be unique, and must
The examples of statements are: follow assembly language naming conventions. An ENDS
Identifiers Operation statement indicates the end of the segment and contains the
Operand Comment
same name as the SEGMENT directive. The operand of a
Directive: COUNT DB 1 ; initialize count SEGMENT statement may contain three types of options:
Instruction: L30: MOV AX,O ; assign AX with 0 align, combine, and class.
Directives: The align option indicates the boundary on which the
The directives are the number of t t segment is to begin; PARA is used to align the segment on
control the way in which s a ements that enables us to
116
1 a source pr
INSIGHTS ON MICROP OCESSORS
ogrnm -mbles and lists
paragraph boundary. The combine option indicates whether
117
PROGRAMMING WITH 8086 MICROPROCESSOR
used to notify the assembler that the instructions or features
to combine the segment with other segments when they ar introduced by the other processors are used in the program.
linked after assembly. STACK, COMMON, PUBLIC, etc e
E.g., .386 - program for 386 protected mode.
combine types. The class option is used . are
to group r e1·atect
segments when linking. The class code 1s for code se'""
o•«ent Dn Directive
7,
stack for stack segment, and data for data segment. ' The Dn directive is used to define data types. Its format is:
\
·ptioD for conventional program:
Program Written in Conventional Full Segment Direct·IVe oescrl
STACK contains one entry, DW (define word), that defines
page 60,132 • 3
2 words initialized to zero, an adequate size for small
title sum program to add two numbers programs,
------------------------------------------ DATASEG defines 3 words NUMl, NUM2 initialized with
• 3291 and 582 and sum uninitialized.
stack segment para stack 'stack'
coDESEG contains the executable instructions for the
dw32 dup(0) • program, PROC and ASSUME generate no executable code.
stack ends The ASSUME directive tells the assembler to perform these
;----- ---------- - -- - - • tasks.
data seg segment para 'data' Assign STACK to SS register so that the processor uses the
numl dw3291
• address in SS for addressing ST ACK.
Assign DAT ASEG to DS register so that the processor uses
num 2dw582
• the address in DS for addressing DAT ASEG.
sum dw?
Assign CODESEG to the CS register so that the processor
data seg ends • uses the address in CS for addressing CODESEG.
• When the loading a program for disk into memory for
code seg segment para 'code' execution, the program loader sets the correct segment
main proc far addresses in SS and CS.
assume ss: stack, ds:dataseg, cs:codeseg Program Written using Simplified Segment Directives
mov ax, @data .Model memory model
mov ds, ax
Memory model can be
mov ax,numl TINY, SMALL, MEDIUM, COMPACT, LARGE, HUGE or
addax,num2 FLAT
mov ax, 4c00h TINY for .com program
int 21h FLAT for program up to 4 GB
mainendp Assume is automatically generated
•
codeseg ends
.STACK {size in bytes]
end main
Creates stack segment
.DATA: start of data segment
121
120 INSIGHTS ON MICRO PROGRAMMING WITH 8086 MICROPROCESSOR
PROCESSORS
.CODE: start of code segment \:;,, tlink filename ➔ makes .exe
4.
DS register can be initialized as \:;,, filename.exe ➔ run the code
• s. V td filename.exe ➔ debug the code [use F7 and F8]
MOV AX, @DATA
6.
MOVDS,AX 6 Assembling, Linking, and Executing
3
:;;.--
ALP Written in Simplified Segment Directives The symbolic instructions that we code in assembly
language are known as the source program. We use an assembler
page 60,132
program to tra~late the sou_rce program into machine code,
title sum program to add two numbers.
1.<nown as the object program. Fmally, we use a linker program to
.model small complete the machine addressing for the object program,
.stack64 generating an executable module.
.data
Assembling
numl dw 3241 The assembler converts source program into object program
num2 dw 572 if syntactically correct and generates an intermediate .obj file or
sumdw ? module. But assembler complains about the syntax error if any and
does not generate the object module. Assembler may create
.code optional output files .1st and .crf (or .sbr) at run time. An .obj file
main proc far is required for linking a program into executable form. A .1st file is
mov ax, @data ; set address of data segment in ds required for error diagnostics or if we want to examine the
mov ds, ax generated machine code. A .crf file is useful for a large program
where we want to see which instructions reference which data
movax, numl
' items.
addax, num2
The assembler calculates the offset address for every data
mov sum, ax item in the dat~ segment and for every instruction in the code
mov ax, 4c00h ; end processing segment. The assembler also creates a header immediately in front
int 21h of the generated .obj module; part of the header contains
mainendp information about incomplete addresses.
; end of procedure
end main For short programs, assembling can be done manually
; end of program
where the programmer translates each mnemonic into the machine
Turbo Assembler (TASM) Assembling p ~anguage using lookup table. The assembler reads each assembly
1. Save the cod . rocess '.115truction of a program as ASCII character and translates them
e text m ASM f
folder where masm and · link filormat and save it to the saine
into respective machine code.
2. Open dos mode d es are stored.
an reach within
3. \> tasm filen that folder.
----;; ; -.-____ ame.asm ~ makes.obj
122 INSIGHTS ON MIC_R_O_ _
PROCESSORS ------- PROGRAMMING WITH 8086 MICROPROCESSOR 123
1
There are two types of assemblers:
Ed ito r
editor Prog .a sm
1. One-pass assembler
Thi assembler scans the assembly language progra
s and converts to object codThi
once e. rn
s assembler has the
program of defining forward references only. The iuntp Prog .asm
instruction uses an address that appears later in the
program during scan, for that case the progranuner ,
defines such addresses after the program is assembled,
Assembling
2. Two pass assembler
A potential problem in first pass is a fonuard reference.
The two-pass assembler typically makes two or more Prog.l•t .Prog.obJ
prog.cr1' Optional
passes through a source program in order to resolve
forward references to addresses not yet encountered in
the program. During the first pass, the assembler reads
the entire source program and constructs a symbol table
of names and labels used in the program, that is, names ptlonal
ROCESSORS -----~~=~~--=-:::==::=.:;;~--r'ii
ADD TBL [BX +SI], CH
PROGRAMMING WITH 8086 MICROPROCESSOR
131
nctions and Interrupts
9. String Addressing: poS fbu ard and Video Processing)
O
This mode uses index registers, where SI is used to p Olllt
. t (t<eY The .
Intel CPU recogruzes two types of interrupts namely
0
the first byte or word of the source string and DI is use dware interrupt when a peripheral devices needs attention
point to the first byte or word of the destination string,w1 to ha! the CPU and software interrupt that is call to a subroutine
string instruction is executed. The SI or DI is automaij en fro~ed in the operating system. The common software interrupts
·
mcremente d or d ecremente d to point. to t h e next bytecaUy
iocad here are INT lOH for video services and INT 21H for DOS
word depending on the direction flag (DF) . or use
services.
E.g., MOVS, MOVSB, MOVSW
Examples: tNT 21H:
It is called the DOS furlction call for keyboard operations
title program to add ten numbers
follow the function number. The service furlctions are listed below:
.model small
, # OOH- It terminates the current program.
.stack 64
.data Generally not used, function 4CH is used instead.
arr db 73, 91, 12, 15, 79, 94, 55, 89 # OlH- Read a character with echo
sum dw ?
•
Wait for a character if buffer is empty
.code
Character read is returned in AL in ASCII value
main proc far
# 02H- Display single character
mov ax, @data •
mov ds, ax Sends the characters in DL to display
movcx, 10 MOVAH,02H
mov ax,O
MOV DL, 'A' ; move 01, 65
lea bx, arr
12: add al, [bx] INT21H
jncll • # 03H and 04H - Auxiliary input/ output
inc ah INT 14H is preferred.
11: inc bx
loop 12
• # 05H - Printer service
Sends the character in DL to printer
mov sum,ax
mov ax, 4c00h • # 06H- Direct keyboard and display
int 21h Displays the character in DL.
mainendp
end main
• # 07H- waits for a character from standard input
132 INSIGHTS ON
MICROPROCESSORS - - -- - ---------=--====~;,;;,;;-11iii33
PROGRAMMING WITH 8086 MICROPROCESSOR
# 08H- keyboard input without echo rNNT21H
• DB "Hello world" '$'
Same as function 0lH but not echoed. cUSLMSG '
# 09H- string display
Displays string in the dat_a area, immediately followed by a
• dollar sign ($ or 24H), which uses to end the display.
Displays string until ' $' is reached.
# OAH
DX should have the address of the string to ~e displayed. • M:OVAH,OAH
; request keyboard input
• # 0AH - Read string
LEA DX, PARA_ UST ; load address of parameter list
• # OBH- Check keyboard status
1NT21H
Returns FF in AL if input character is available in keybo
~~- ~ Parameter list for keyboard input area :
p ARA_LIST LABEL BYfE; start of parameter list
Returns 00 if not.
MAX_LEN DB 20; max. no. of input character
• # OCH- Clear keyboard buffer and invoke input functions
such as 01, 06, 07, 08 or 0A. ACT_ LEN DB ? ; actual no of input characters
AL will contain the input function. KB-DATA DB 20 OUP ('); characters entered from keyboard
INT 21H Detailed for Useful Functions LABEL directive tells the assembler to align on a byte
boundary and gives location the name PARA _LIST.
• #0lH
p ARA UST & MAX_LEN refer same memory location,
MOV, AH 0l H; request keyboard input INT 21H MAX_LEN defines the maximum no of defined characters.
Returns character in AL· IF AL_ - nonzero value operation ACT_LEN provides a space for the operation to insert the
echoes on the screen· If Al- ' pressed
- zero means that user has
actual no of characters entered.
an extended function key such as Fl OR h ome.
KB_DATA reserves spaces (here 20) for the characters.
• #02H
37
_ _ _ _ _ _ _ _P_R_OG_RA_M_M_IN_G_WIT_H_80_88-:-:M::IC=R::OP;;:;:R;-;;;OC:;;E;,;S;;SOR~l\l11°i1
136 INSIGHTS ON M -
ICROPROCESSORS - - - ----
~ODIi· Read pixel dot
# oAH-display character at cursor
Reads a dot to determine its color value w hich returns in
MOV AH, OAH
AL-
MOV Al, Char MOV AH,ODH
MOV BH, page _no MOV BH, 0 ; page no
MOV BL, value MOV CX, 80 ; column
MOV eX, repetition MOV DX, 110 ; row
INTlOH 1NT10H
# Olm- Set color palette #OEII- Display in teletype mode
✓ Sets the color palette in graphics mode Use the monitor as a terminal for simple display
✓ Value in BH (00 or 01) determines purpose of BL MOV AH,OEH
✓ BH= OOH - select background color, BL contains 00 to MOV AL,char
OFH (16 colors) MOV BL, color; foreground color
✓ BH = OlH - select palette, BL contains palette
INTlOH
MOV AH, OBH #OFH - Get current video mode
MOV AH, OBH MOVAH,OFH
MOV BH, OOH; background
INT10H
MOV BH, 01H; select palette Returns values from the BIOS video.
MOV BL, 04H; red AL= current video mode
MOV BL, OOH; black AH= no of screen columns
INT21H
BH = active video page
INT21H
Examples:
#OCH- Write pixel dot Write a program in 8086 to convert uppercase letters into
1.
Display a selected color
lowercase.
AL=color of the pixel, ex--coumn
1
.model small
BH=page number, DX= row ,
.stack 99h
MOVAH, OCH
.code
MOV AL, 03
mainproc
MOV BH,O mov ax, @ data
MOVCX,200 mov ds, ax
MOV DX,50 mov si, offset str
lNT lOH m: mov dl, [sil
· I at column 200
It sets pl)(e mov cl, dl
,row SO
cmp dl,' $'
138 INSIGHTS ON
_ _ _ _ _ _ _P_R_OG
_ RA_M_M_IN_G_WIT_H_80_86 1 l9
_ M-:::IC=RO::P:::R::OC;:;;E:;SSO;;:;;R;-7\11t
NIICftOPROCESSORS
je 11
jen inC Si
cmp di, 60h
inc bl
jl 1 jmp 12
k: mov dl, cl mov cl, bl
mov ah, 02h 11:
mov ch, 00h
int 21h dee si
inc si mov al, [si]
jmpm 13:
mov [di], al
I. mov dl, cl
dee si
add dl, 20h
inc di
mov ah,02h
loop 13
int 21h
mov ah,09h
inc si mov dx, offset str2
jmpm
int 21h
n: mov ax, 4c00h
mov ax, 4c00h
int 21h
int 21h
mainendp
.data
mainendp
str db "I am Mr Rahul", '$' end main
3. Write a program to input characters until 'q' and display
end main
the entered string. ·
2. Write a program·m 8086 to reverse the string
model small · .model small
.stack 100h .stack 100h
.data .data
str db 50 dup ('$')
strl db "My name is Rahul" '$'
str2 db 50 dup ('$') ' .code
.code main proc far
main proc far mov ax, @ data
mov bl,00h mov ds, ax
mov ax, @ data mov si, offset str
mov ds,ax 12: mov ah, 0lh
mov si, offser strl int 21h
mov di, offset str2 cmp al, 'q'
12: mov di, [si] je 11
cmp di,'$' mov [si], al
inc si 11
140 INSIGHTS ON M
ICROPROCESSORS PROGRAMMING WITH - MICRCJPROCEss<>R '
. f)i , p/aY if numbers are with 1 digit
,mr 12 ,Jott• mo v ex, 05h
men' ,1h, 09h 1
m ov s1, OOh
rnnv dx, offset str
rnov dt arr [s i]
int 21h ):
add di, 30h
mov ax, 4cOOh
rno v ah, 02h
int 21h
int 21h
main endp rnov dl,''
end mam rnov ah, 02h
Wri te a p rogram to sort the numbers in d escend 1ng
· 0
4. dosseg rd ~,. int 21h
inc si
.model sm.aJJ
loop 1
.stack 100h
mov ax, 4c00h
.code
int 21h
main proc far
mov ax, @ data rnainendp
mov ds, ax Write a program to add f irst 100 n tu 1
5. display the result in the screen. a ra even numbers and
mov dx, 4h
dopass: mov ex, 4h
.model small
mov si, OOh .stack 100h
check: mov al, arr [si] .data
cmp arp [si+l], al ten dw 10
jc noswap .code
mov bl, arr [si + 1) main proc far
mov arr[si +1], aJ mov ax, @ data
mov arr fsi], bl mov ds, ax
noswap: inc si mov ex, 63h
loop check mov ax, 02h
dee dx mov dx, 04h
jnz dopass 11: add ax, dx
mov ax, 4c00h add dx, 02h
int21h loop 11
main endp 12: mov dx, 0000h
.data div ten ; dx: ax / 10
arr db 8,2,9,4,7 inc ex
end main add dx, 30h ; remainder
pushdx
114:42~1,;,N~SKfGiHHTrT:S~ODIN;-Mf<MIC:RROOPPiRtcO;:C;.ES~S~O-; ;-RS- - - - - - - - - - -
PROGRAMMING WITH 8081
aJll in 8086 to add 10 11ixteen bit numbert1 in
gr
cmP ax, OOh ; quotient wrtte ~ pro
t1tO.-Y table
7,
je13 111e d••I .; n1.1 ll
,t1lll ~
;mp12 .st,,d..: ~
,z
papdX nun, dw dup (2)
}3:
movah,02h , th.,. dup (J)
0011
int 21h -.u 1nh d w 0
1oop13 s t11nl d w ll
rnov ax, 4cOCJh
.cod
int 21h
maiJtendp
end main
Write a program in 8(186 to generate the multiplication
6.
table.
.model small ""
ll :
.stack 32
.data
numl db5
num2db 1 12:
loop 11
tab db 10 dur (?)
.code tnl
main proc far main ndp
mov ax, @ data dm in
movds,a
movb ,0
movcx, 10
11: mov al, numl
mulnum2
mov tab [b ), I
Inc b
incnum2
loop 11
mo 4c00h
int 21h
mainendp
end main
~,., I111II 111 I ""' 11 11 t I", 1lq I !I rvlc
11111• q " wl . I 11
•· 1otl Viii t
Pt,,
lh ,I I'''" 1N1
\ I '" q11 [11tllllllrt )It '
l I Ill' I II i,1,. d s
1Jell ~1r1U olur lo of I g~l'I p ol ut ""
, I,· ii\ do•f111• ,I It tV
,,,11.. '", I ·Ill r,1q ,f, nde , ,.,,.1t1'll' ,1, C1111111 1, 11 1,, I ,r,utle
column
f, d11, 1
th• 1111111111 I I
• ' "' l , ,llrd 1111111
' nil\' 11 u1nbt•1 111 11lt1 tec; 111 11
Ill l•d 11
1f•
II • , i,tJ,,
''" ~,>".40 nl11r p, '',(,( Ji</lf ,, )
()0
qne11I C()]or 8 ' l(,fl,u\()(I If,
, • I ·ltrr 1•1Pg1,1111 (>fg<\lli7fltiwl 2•,1<40
I 11, 1 ,,r,1f; it OI < ,,lorq
• ,.,j,w of
f ulit,11( S l Ir I,cii-;,., ,,
ii pmgrnm bctflll SE' d l'l t:'t IR
, l, he 720•400 I f,
IJ ( olor 4
• · 1~1,·d
m11rt I It ,11 II' •~ 0 '
n (ln"oin" rnninl nancr of prog,nrr 1q bn
-oz 25><80
color
l t:: rs ,n 11, ,. ,rau~e 4 720,,.400 I(,
'I
t1 t1 , • • • .
• pr(l(r<Ju rr~• ,.•rr readily ident1f1ed for mod1f1cnl1on -------
03(bY
25><80 color
color!\
A CALL il procedure within the same code segmen t is default) 720><400 16
10 25><80 Mono 0
Nf:A R CALL< A f,AR CAIL ca lls a procedure lab I d Pl\ R,. 07 hromc colors
ros•rJ:,ly in anothrr rodr ~ gmrnt
D!SPLA Y PROC NEAR Pages Resolution Noof
-Graphic Color
MOY AH,091-1 color•
mode
MOY DX, OFFSET STR 8 320><200 4
04 Color
INT 21H 8 320><200 4
05 Color
RET 8 640><200 2
06 Color
DISPlA Y ENDP 8 320><200 16
OD Color
✓ To display number contained in [BX] 4 640><200 16
OE Color
D!SPLA Y PROC NEAR 2 640>e350 1
OF Mono
MOYDI, [BX] chrome
2 640,c350 16
ADDDl,30 10 Color
1 640,c480 2
MOYAH,02H 11 Color
1 640•480 16
INT21H 12 Color
13 Color 1 320•280 256
RET L
DISPLAY ENDP
Attribute
Background ~
Attribute: BL R G B 1 RGI
Bit number: 7 6 54
I - Intensity, BL - Blink
1111 111,
A
111 Ill 1 ""' '
II d ,t.,
111 w ,II, Ill
, ol di, 1ft
v11I dh "v td• motl,I",'$'
II
"I Ill Ill
t:iuunpl : Sn n
I, Writ a pmgt1111 to dl1pl y strlnM I ( IU,40) with 11
b1rk11rotmd nd red for 11round K •1•11
do 1•~ oil
,111od1•I m II
. I, I k l(Klh
,rod,•
111 In pn1t l,11
mov ,, , (U) ti ,t 1
IIIOV d / '
nmv I, off ,•t v I I
12: mov h, ()'Jh ; f' I 1 11r II J'O Ilion
mov dh, row
mov di, 1 ol
inl JOh
11111V ,I, I ii
cmp ,I, '$'
I•· II
rnov h, 119h
mov dh, row
INlfGHfSON
M1c110,11oc 011
movcl,ndws
~line
Wnt an a• rnbl l.anr• program to rHd • tring f
er con\f'J1 it 10 upp« cue, count the nu .... b to again•
th r \I , .--1 i ---L. 1· ·•• er mov dL[si)
;-ord and di pl.a uch wun, n cau1 •n~. (2061 Aslr, Of
U.'111}
911bdl,20h
I IJ
;,re down
nrwline
cl.a
ol words as','$' a,cbl
.town: intZlh
ineal
7
b255 dup (7)
.....
loop .....
macro
•
ah,02h
movdl,Oah
int 21h
movdl,Odh
tn 2th
pop )I
newlmemdm
mamprocw
IJIOY~
mcwda,e
•
main pfOC far rnov ax,@data
mov ax,@data rnov ds,ax
movds,ax next:
next: rnov si,offset array
mov si,offset array rnov bl,0
mov bl,0 rnov cx,4
mov cx,4 again:
again: rnov al, [si]
mov al,[si] inc si
inc si cmp al,[si]
cmp al,[si] jadown
jc down mov dl,[si]
mov dl,[si] mov [si],al
mov [si],al dee si
dee si mov [si],dl
mov [si],dl inc si
inc si mov bl,01
movbl,01 down:
down: loop again
loop again dee bl
dee bl jz next
jz next mov si,offset array
mov ax,4c00h movcl,05
int 21h nxtbyte:mov'al,[si]
mainendp aam
end main or ax,3030h
Title arraninn · d
o---•8 in ecending order movbx,ax
.model small mov ah,02
.stack
mov dl,bh
.data
int 21h
array db 4,37,13,50,2,,$' mov dl,bl
.code
int 21h
main proc far
mov dl,0
152 INSIGHTS ON MICROPR _____ ___P
_R_OG_RAM_II_ING_WIT
_ H_IOll
~ ll:::l=CR=:OP:=ROC~ESSO;;;;;:R;--1~
: 1i53,
ESSORS
mt 21h !llOV ah, 02h
inc si int 21h
loop nxtbyte !llOV di, Oah ; control character for for next line
mov ax,4c00h !llOV ah, 02h
int 21h int 21h
mamendp
endlil
end main . e macro ; macro defined print space gap
Write a progra m to read a string and separate the \\>or.,s
., spaC h
3. !llOV di, 09
trt
from the s n ·. g Display each word at the center of ea ch mov ah, 02h
. f
line o a c e 1 ar screen with blue background and cya n
foregroun d • [2062 Bhadra] nt21h
⇒ endm
model small input macro prlst ; macro defined to input
.stack 100h ;keyboard input
.data mov dx, offset prlst
count db OOh movah, Oah
promptl db ' enter your string: ' , '$' int 21h
pkey db' press any key ......... ' , '$' endm
temp db 50 dup ( "$" ) setwindow macro
paralist label byte ; table of the byte for keyboard input movah, 06h
maxchar db 79 ; maximum limit to enter characters mov al, OOh ; for entire screen
actlen db ? ; gives how many Character are entered by user mov bh, 13h ; blue background and cyan foreground
kb_buff db 80 dup ('$') ; this is actually the place to hold entered movcx, OOh
;charactered mov dh, 24
.code mov dl, 79
mainproc int 10h
print macro msg ;defining macro to displaystring endm
mov dx, offset msg setmode macro
mov ah,09h movah,OOh
int 21h
moval, 03h
endm
int 10h ;mod echange and screen cleared
nextline macro ; defining macro toadvance to nextline
d·15
mov di, Odh ; control character for from feed playcenter macro msg
movdh, 12
154
INSIGHTS ON MICROPROCES50tls
------ ----===:-:::::=;;uii,;ioiPRO(;ESS<O>RRllj1!15555
PROGRAMMING WITH BON MICROPROCESS
; initial row : column
movdl, 40 int 21h
mov bl, 15 rnov ax, 4cOOh ; exit to operating system
mov si, offset msg
2h . function code for set cursor int 21h
nxtdsply:mov ah, 0 '. set cursor in the beginning Jllairl endp
int 10h '
mov ex, 1 , ex contains the no of characters to
. nd !llain
movah, 0ah
;display at a time
; display character at cursor
4, ;y
e W ·te an assembly language program for 8086 to sort an
of ten numbers stored. in memory. Display the
numbers in the screen after sorting. [2062 Bhadra]
mov al, (si) .model small
~
movbh,.OOh ; page 0
.stack
int 10h .data
incsi ; for next pass array db 79,4,37,13,56,63,50,44,23,2,'$'
inc di
.code
dee bl main proc far
movbh, [si] mov ax,@data
cmp bh,' '
mov ds,ax
jnz nxtdsply
next:
incdh
mov si,offset array
mov di, 39 ; change row and column to nextline middle movbl,O
dee bl
movcx,9
jnz nxtdsply
again:
endm
mov al,[si).
mov ax,@data
inc si
movds, ax
cmp al,[si)
moves, ax
jcdown
print promptl
mov dl,[si)
input paralist
mov [si],al
set mode
decsi
set window
mov [si],dl
displaycenter kb_buff
nextline inc si
movbl,O1
printpkey
mov ah, 1 dOWn:
; wait for any key ........ hold screen.·····
156 INSIGHTS ON MICROPROCESSofts .
dee bl count db 0
jz next code
mov si,offset array rnain proc far
movcl,Oah mov ax,@data
nxtbyte:mov al,[si] rnov ds,ax
aam rnov ah,0ah
or ax,3030h rnov dx,offset instr
mov bx,ax
int 21h
mov ah,02 mov bx,offset actstr
mov dl,bh
movcx,0
int 21h
mov cl,nchar
mov dl,bl
next:
int 21h
push ex
mov dl,O
mov si,offset vowels
int 21h
movcl,0ah
inc si
mov al,[bx]
loop nxtbyte
up:
mov ax,4c00h
cmp al,[si]
int 21h
jnedown
mainendp
inc count
end main
down:
5. Write an assembly language program for 8086 to read a
string count the number of vowels in the string and inc si
display the string and its vowels count in a clear screen. loop up
[2063 Kartik] inc bx
⇒ .model small pop ex
.stack loop next
.data mov [bx],'$'
'i' ,
vowels db 'a','e', 'o' ,
'u' ,
'A','E','I','0'
,'U' mov ah,OOh
str db 20 dub(?) mov al,03
instr db SO intlOh
nchar db? mov ah,09
actstr db SO dup (?) mov dx,offset actstr
int 21h
INSIGHTS ON MICROPROCE5soRs
159
mov al,count ; for every no, ten times
rnov cx,10
aam
or ax,3030h
Jabell:
movbx,ax
1 arrnum [bx]
rnov a,
mov ah,02 ; ax=al*dl
rnul dl
movdl,bh
int 21h
;for display
mov dl,bl
push bx
int 21h
push ex
mov ax,4c00h push dx
int 21h movbx,O
main endp mov cx,10
end main no_of_digits:
6. Write a program to generate multiplication table of five movdx,O
numbers stored in memory as array, store the result and div ex ;{ dx: ax/ ex= ax dx/ ex)
display 'in following format.
5 10 15 20 25 30 35 40 45 50 adddx,30h
3 6 91215 18 2124 27 30 ... ........ . pushdx
[2064 Shrawan]
⇒ .model small inc bx
.stack cmp ax,O
.data ja no_of_digits
arrnum db 5, 4, 3, 6, 7 mov ah,02
,code
mov ex, bx
main proc far
mov ax, @data
mov ds,ax popping:
popdx
mov ax,O Int 21h
movcx,5 loop popping
movbx,O . hich were
; index popdx ; popping respective register w
pop ex
total_no_of_tab]e:
pop bx
mov di, 1
push ex ; runs for 1 to 10 for each no. ; display ends here
; storing for nested loop
160 inc dl
INSIGHTS ON MICROPRQ
CESSORS
- - - - - - -------::-:-:-:::::~;;.;~MIDICCIRUO>PPRIROCDCEEPSSOR
PROGRAMMING WITH 80B6
I"'
loop Jabell mov a,h,09h
inc bx mov dx,offset msg
popcx int 21h
mov ah, 02h printendm
movdl,Oah
int 21h printmsg1
mov di, Odh movah,Oah
int 21h mov dx,offset maxchar
loop total_no_of_table int 21h
mov ax, 4c00h
int 21h movbx,O
mainendp mov cx,O
end main mov cl,nchars
7. Write down an assembly language program to read a string mov si,offset actstr
and count the no of vowels in the smng. Display the no. of mov di,offset newstr
vowels in the string and the string without the vowels in it
in a clear screen with reverse atmbute. [2064 Poush} again:
⇒ .model small mov ah,[si]
.stack cmp ah,'a'
.data jldown
maxchar db 30 cmpah,'z'
nchars db? jg down
actstr db 30 DUP (0) subah,20h
msgl db 'Enter any text: $' down:
msg2 db 10,13, 'No. of Vowels=$' cmpah,'A'
jevowel
msg3 db 10,13,'Here is string without vowels:$'
countdbO cmpah,'E'
newstr db 30 dup ('$') jevowel
.code cmp ah, 'I'
main proc far jevowel
mov ax,@data cmp ah,'0'
mov ds,ax jevowel
cmpah,'U'
print macro msg
jevowel
162
INSIGHTS ON MICROPRocessoRS
----
ASSUME ds: data ,cs: code
mov ah,[si]
mov ax , SEG data
mov [di],ah
mov ds, ax
inc di
jmpNEXT
vowel:inc bl rint macro msg
NEXT:inc si P movah,09h
loop again mov dx , offset msg
mov count,bl int 2th
mov bh,70h ; reverse attribute printendm
movax,O ; code for clear screen print msgl ; output string using macro
mov dx,184Fh
movah,09h
int 10h
mov dx , offset text
printmsg2
movah,02h int 21
mov dl,count mov bx , 0000h ; to count no. of vowels
or dl,30h mov ex, LENGTH text
int 21h mov si, offset text
printmsg3
print newstr
again : mov ah,[si]
mov ax , 4c00h
cmp an, 'a'
int 21h
jl down
mainendp
cmp ah, 'z'
end main
8. jg down
Write an assembly language program to get a string input;
sub an, 20h
count no. of vowels and display message 'even vowels' on
the screen if the count is even otherwise display 'odd
vowels'. [2065 Chaitra] down: cmp ah , 'A'
⇒ # include io.h
jevowel
data SEGMENT
cmp ah, 'E'
text db 30, ? , 30 DUP($) jevowel
rnsgl db 10 , 13 , 'enter the text:$' cmp ah, 'I'
msgo db 10,13, 'odd vowels: $' jevowel
data ENDS msge db 10,13, , even vowels: $' cmp ah, 'CY
code SEGMENTs jevowel
164 cmpah , 'U'
INSIGHTS ON MICROPRO
CESSORS 165
PROGRAMMING WITH - MICROPROCESSOR
jevowel and al,Ofh
jmpNEXT rnov dh,al
inc bx jnt2lh
vowel:
loop again and al,Ofh
NEXT:
rnov dl,al
mov ax, bx rnov al,dh
div 2 rnovbl,Oah
166
INSIGHTS ON MICROPR
OCESSORs
----
end main
RAMMINGWITH-~
1f7
1
Write a program in 8086 to read a single digit number and
10. Write an assembly language program to calculate 8
urn of 11. display the multiplication table of that number as 2 4 6 8
the series l2+22+32+42+ .......upto ten terms and displ ay the
1618 20 if the user enters digit 2. [2067 Shrawa!~
result. [2066 Shrawan] 1214
.model small
⇒ # include io.h ::>
data SEGMENT .stack
sum db 4 DUB('$') .data
mldb 10 , 13, ' the sum of square : $' .code
main proc far
data ENDS
mov ax, @data
code SEGMENT
ASSUME ds : data , cs : code mov dx, ax
mov ax , SEG data
mov ah, 07h ; console input without echo
movds, ax
mov dx, 0000 stores sum int 21h
mov ex, 0010 ; counter mov ex, 10
mov al, 01 mov dl, 1
again: movbh, al sub al, 30h ; to decimal value
mulbh ax+-al * an labell:
add ax,dx mov ah, 0
mov dx, ax push ax
inc al muldl ; ax=al*dl
loop again
itoasum, dx ; for display
push ex
movah, 09h push dx
mov dx , offset ml ; display msg ml movbx, O
int 21h movcx, 10
168 INSIGHTS
ON MICROPROCESSORS 169
PROGRAMMING WITH 8088 MICROPROCESS0R
cmp ax,O .Jtlodel srnall
jano_of_digits .stack 100h
movah,02 .data
mov ex, bx countdbOOh
prornptl db 'enter your string:',',$'
popping: prornpt2 db ' you entered : ' , '$'
prornpt3 db' converted string:','$'
popdx pkey db 'press any key','$'
int 21h paralist label byte ; table of 3 bytes for keyboard input
loop popping maxchar db 79
actlen db?
mov dl, 32 kb_buff db 80 dup ( '$')
movah,02h .code
int 21h mainproc
print macro rnsg ; defining macro to display string
popdx mov dx, offset rnsg
pop ex movah,09h
int 21h
; display ends here printendm
nextline macro ; defining macro to advance to next line
inc dl ; control character for form feed
movdl,Odh
pop ax ; control character for nextLine,
mov ah, 02h
loop labell
mov ah,02h
int 21h
mov ax, 4c00h
nextline endm
int 21h
space macro ; macro defined print spacegap
mainendp
end main mov dl,09h
12. movah,02h
Write an assembly Ian
memory in data guage program to read a string frolll int 21h
I segment. Chan
ower case and vice versa . ge all the upper case letterS to spaceendm
[Note: AScn code for A~ Display the result on the acreen, · d · ut
mput macro prlst ; macro defined to input keyboar mp
...... 2=9(}, a~ ...... z=122]
[2067 MJmgsirl
mov dx, offset prlst
170
rnov ah, Oah
INSIGHTS
ONMtCROPRnr.
-""SSORS 171
PROGRAl8MIMG 111TH - lll'ROPROCESS0R
crnP al, 61h
int 21h
jc uplast
inputendm
crnP al, 7ah
mov ax,@data
jnC uplast
mov ds,ax ; convert to upper
sub al, 20h
moves, ax
mov [si], al
print promptl
input paralist uplast:
nextline inC Si
···········;;;;;;;;;;;;;;;;;;;;;;;;;,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,
print prompt3
print kb_buff ; to lower ························;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
nextline
.... ······ .........;;;;;;;;;;;;;;;;;;;;;;;,,,,,,,,,,,,,,,,,,,,,,,, .............. .
;;;,,,,,,,,,,,,,,,,,,, ....................;;;;;;;;;;,,, ,,,,,,,, If,,
········ .........;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,
print pkey
mov ah, 1 tolower proc near
;wait for any key .. ..... hold screen .. .
int 21h mov si, offset kb_buff
mov ax, 4c00h movch,00h
; exit to operating system. t of characters entered
mov cl, actlen . ex contains the coun
int 21h I
by user
mainendp
chkdn:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,,,,,,,,,,,,,,,,;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov al, [si]
;input: supplied with read string from keyboard cmp al, 41h
;output: converted to uppercase jc dwnlast
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,,,,,,,,,,,;;;; cmp al, 60h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; jnc dwnlast
toupper proc near add al, 20h . convert to lower
I
-
)
~
lea dx, strl
mov ah, 09h
IOI)
SID
'
int 21h 1MP • UAD\' 10D
'
lea dx, string
mov ah, 09h •
JO ALI
int 21h » asn T ~
Sl(IIAI.I
mov ax, 4c00h llffll
....., ,. oil
int 21h
iiM ,. I
, J2 ii>
mainendp
end main
AD, •
asr,.s
INft
,. JI fl.
"°·
AD,
:II
27
llll'l II 2' . SfAt\lS
AD,
• UADY
,, ,, ISl(lll,u.l
I
AD, 25
AD, 21 11111,D
,. ,. iliiftii
AD, u ,. , ~
AD, D
GND 21
MSPliDala
(b)
(a)
Figure 4.1 (a) Pin diagram of 8085 (b) Logical schematic of pin diagram
189
188 INSIGHTS ON MICROPROCESSORS
- --- - - _ _ _ _ _ _ _ _ _..--! MICROPROCESSOR SYSTEM
Nfultiple"e
d Address{Data Bus
The microprocessor is capable of performing var· AD0-AD1
. . . ious • ultiplexed set of lines used to carry the lower
computing functions and making dec1s10ns to ch~ge the sequence These rn
• S-bit address as well as data bus.
of program exec ution. In large computers, a CPU rmplemented 0 order
. the opcode fetch operation, in the first clock
one or more circuit boards performs these computing function: ouring
The microprocessor is in many ways similar to the CPU, bu~ • the lines deliver the lower order address Ao - A7•
cycle,
includes the logic circuitry, including the control unit, on one chip. In the subsequent IO/memory, read/write clock cycle
The microprocessor can be divided into three segments .for the sake • . es are used as dat& bus.
the 1in
clarity, arithmetic/logic unit (ALU), register array, and control • The CPU may read or write out data through these
unit.
lines.
8085 is a 40 pin IC, DIP package. The signals from the pins
5
can be grouped as follows: ~: L---------:~s jAddressbus
1. Power supply and clock signals ALEL-----i
2. Address bus 808S AD1 _ _.EN
___..., A1
3. Multiplexed address/ data bus Latch A0
4. Control and status signals D7 Joata bus
5. Interrupts and externally initiated signals L--------Do
6. Serial I/0 ports
Figure 4.2 Multiplexed address/data bus
1. Power Supply and Clock Frequency Signals
Control and Status Signals
• Vee: +5 volt power supply 4.
- &WR )
• Vss: Ground These signals include two control signals ( RD
- Si d So) to identify the
• Xl, X2 : Crystal or R/C network or LC network and three status signals (IO/ M ' an . . al (ALE) to
connections to set the frequency of internal clock . d one special sign
generator. nature of the operation, an .
. . £ the operations.
indicate the begmrung o -
• The_frequen~y is internally divided by two. Since the
• ALE (output) - Address Latch Enable d
basic operating timing frequency is 3 MHz a 6 MHz the lower or er
crystal is connected externally. ' This signal helps to c:~tu;~tiplexed address/
• CLK (outpu~)-Clock output is used as the system clock address presented on t
•t · the pulse,
8085 beginS an
for peripheral and d ev1ces
• data bus. When i is the separate
interfaced with the ADo - ATh a5
microprocessor. operation. It generates
2. Address Bus set of address lines Ao -A,.
vooevice
• As-A1s RD (active low) - Read Memory or
• It carries the most significant
.
• location or
lected rnernory .
address th . 1 s o f the me,....,.,
8 b't _,_
This indicates that the se that the data bus is
8
or e bits of the 1/0 address. nd
1/0 device is to be read a 191
190 MICROPROCESSOR SYSTEM
INSIGHTS ON M ICROPR - - -
OCESSORS
'[here are five hardware interrupts called,
.
Titis status signa1 m
· d'icates that the read / . }{old (Input)
operation relates to whether the write • This indicates peripheral controller requesting the bus.
device. memory or I/0
HLDA (Output)
It goes high to indicate an I/0 operation.
. • This indicates the acknowledgement for the Hold
It goes low for memory operat'
Statu · wns. request.
s signals are used to kn h
of the microprocessor. ow t e type of current operation READY (Input)
• It is used to delay the microprocessor read and write
Table 4.1 Status signals oif8085 microprocessor
. cycles until a slow responding peripheral is ready to
-
microprocessor is reset. en the 1NTR
M/10
4.2 Pin Configuration of 8086 Memory/IQ
DT/R Controls
HOLD
OMA
Maximum Minimum intertace RD
Mode
HLDA
Mode Vee WR
GNO
vcc DEN
AD1,1 Mode MNMJ +----READY
A0 1• StleCI
AD13
A10 / S 3 T
AD12 CLK
A17 / S 4 Clock
A0 11
A 10 /S 5
A0 10 Figure 4.4 Pin details with signal groups for 8086 microprocessor
A,o i S.
AD0
BHE1s 1 • The _Microprocessor 8086 is a 16-bit CPU available in
A0 0
MN/Mi("° different clock rates and packaged in a 40 pin CERDIP
A07
RD or plastic package.
AD,
AO•
8088
M1croprocesso,
R°a,m. HOLD • The 8086 operates in single processor or multiprocessor
Ra1Gf, HLDA configuration to achieve high performance. The pins
AD,
~ "WR'" serve a particular function in minimum mode (single
AD,
i
....--:;;::;: (Interrupt Acknowledge): This signal is
The following signal descriptions are common for b Oth 1N'fA USed for
t acknowledge. When it goes low, the proc
modes. jJlterruP essor has
ted the interrupt.
• ADwADo: These are the time multiplexed memory I/o accep
LE (Address Latch Ena~le): This output signal indicates
address and data lines. !e availability of the vahd address on the address/ data
• Ai,JS 6,A1rjS 5,A 17/S4,A 1f/S3: These are the time multiplexed
\jJleS.
address and status lines. The address bits are separated frolll
the status bit using latches controlled by the ALE signal. vr/R (Data Transmit/Receive): This output is used to
decide the direction of data flow through the trans-receivers
• BHE /S-r; The bus high enable is used to indicate (bidirectional buffers). When the processor sends out data,
transfer of data over the higher order ( D1s-Da ) data bus. this signal is high and when the processor is receiving data,
this signal is low.
• RD (Read): This signal on low indicates the perip
~ (Data Enable): This signal indicates the availability of
that the processor is performing memory or 1/0
valid data over the address/ data lines. It is used to enable
operation.
the trans-receivers (bidirectional buffers) to separate the data
• WR (Write): This signal on low indicates the periph from the multiplexed address/ data signal.
that the processor is performing memory or 1/0 HOLD, HLDA (Hold Acknowledge): When the HOLD line
operation. goes high, it indicates to the processor that another master is
requesting the bus access. The processor, after receiving the
• READY: This is the acknowledgement from the slow d
HOLD request, issues the hold acknowledge signal on.
or memory that they have completed the data transfer.
The following pin functions are applicable for maximum
• INTR (Interrupt request): This is to determine
mode operation of 8086.
availability of the request from external devices. If
~ terrupt request is pending, the processor enters S2, Si, So (Status Lines): These are the status lines which
interrupt acknowledge cycle.
reflect the type of operation, being carried out by the
• TEST : This input is examined by a 'WAIT' instru ' processor.
Table 4.2 Status signals of 8086 microprocessor
the TEST pin goes low, execution will continue, else
-S2
•
processor remains in an idle state.
~L~ (Clock input): The clock input provides the
- 0
S1
0
So
0
Indication
Interrupt Acknowledge
timing for processor operation and bus control activity. 0 0 1 Read I/O Port
0 1 Write I/O Port
The following pin 0
0 1 Halt
operation of 8086: 1
1 0 Code Access
0
• 1 0 Read Memory
M/ IO (Memory/IO) : When it is low, it indicates the 1
1 1 Write Memory
is having an 1/0
. •
operation, and when it is high, it indi 0
1 1
-----
that the CPU 1s having a memory operation. 1 Passive -
196 INSIGHTS ON MICROPROCESSORS
_ _ _ _ _ _ _MIC
_ R _OP
_ R_OC_E
_SS -
-:-0=:RSYSTEM - ,97
1 sus: The control bus is a group of lines used t
LOCK : This output pin indicates that other system b 0 0
• 3, contr h access to control signals and the use of th d
ol t e e ata
master will be prevented from gaining the system bus, Whi.: contr d s bus. The control signals transmit b th
d ad res . . 0
the LOCK signal is low. ail d and timing information between the system
corrunan The timing signals indicate the validity of data and
odules.
RQ / GTo , RQ / GT1 (Request/grant): These Pins are
• J1l
ddress
information, where as command signals specify
d S f th
used by the other local bus master in maximum mode, to a . to be performe . ome o e control signals are:
operations
force the processor to release the local bus at the end of
,. 6 ory Write ( MEMW ): It causes data on the bus to
processor current bus cycle. • ,,.eDl
1
1.
Data Bus
17 Op-Code Fetch Machine Cycle
lll.i The first operation in any instruction is op-code fetch. The
SSYNC
IL in
croproc
ernory r .
.
essor needs to get (fetch) this machine co e
.
d from the
ocessor can
F"igure 4.6 Asynchronous read operation bei,;h egiS ter where it is stored before the nucropr
"'"'' to exec t th .
=-=- ---- I201
200 INSIGHTS ON MICROPR ESSORS
------ u e e mstruction.
------------------
IIICRQMOCESSOR SYSTEM 1
Let's consider the instruction MOV C, A stored at
location 2005H . The Op-Code for the instruction is 4FH :~tnory
ORDP.ll Ml!NOll
Code fetch cycle is of 4 clock cycles. Op.
SIGNAL
C LOCK
I .....
I
■.
. 11•
ALE i
I, Figure 4.8 Timing diagram for memory read machine cycle
IOIM,S,.s. I -
!!I ~
Step 1 : First machine cycle (op-code fetch ) is identical for timing
diagram of op-code fetch cycle.
Step 2: After completion of op-code fetch cycle, 8085 places the
Figure 4. 7 Timing diagram for apcode fetch machine cycle
address 2001 on the address bus and increments PC to
Stepl: Microprocessor places the 16 bit memory address 2002H. ALE is asserted high, IO/ M =0, 51=1, So=0 for
Program Counter on the address bus. At T1, high or
address (20) is placed at As-A1s and lower order ad memory read cycle. When RD = 0, memory places the
(05) is placed at ADo- AD7 ALE signal goes high. IO/ data byte 32H on the dada bus.
goes low and both So and S1 goes high for Op-Code 3. Memory Write Machine Cycle
Step 2: The control unit sends the control signal RD The memory write machine cycle is executed by the
processor to write a data byte in a memory location. The processor
, .... .
· .,. the memory chip and active during T2and T3. takes, 3T states to execute this machine cycle.
Step 3: ~e byte from the memory location is placed on the
us that is 4F into Do-D7 and RD goes high impedance.
Step 4: The instr uc ti on 4FH is decoded and content
accumulator will be copied into re<nster C dn.-ino
cycle T4 • o· --"D
2. Memory Read Machine Cycle
Let's consider the instructi
location 2000H. on MVI A, 32 H stored at
• The IN instruction uses this machine cycle durin .' . ,, 1 Port Address
execution. g the
SIGNAL
CLOCK
... ~......
. ·. I I1/0 Port Address
1111 ,I 10/M=I, S =O, S =l
_, ••I-·
Data (D7-D8) Figure 4.11 Timing diagram for 1/0 write machine cycle
•
- l 1•
• the MEMR signal and processor fetches instruction code
D3 using the data bus.
Figure 4.10 Timing diagram for l/0 read machine cycle Step 2: In machine cycle M2, the 8085 microprocessor places the
next address 2051 on the address bus and gets the device
5. 1/0 Write Cycle
address 01H via data bus.
Let's consider the instru f
location 2050H. c ion OUT 01H stored at m st'P 3: In machine cycle M 3, the 8085 places device address OlH on
low-order as well as high-order address bus. IO/ M goes
2050 D3
high for IO and accumulator content are placed on data
2051 01 bus which are to be written into the selected output port.
Op-Code Fetch Cycle
4T
Examples:
Memory Read Cycle
3T
I/O Write Cycle 1. Timing diagram for STA S26AH
3T
• ST A means store accumulator. The contents of lhe
accumulator is stored in the specified address (526 AH) .
- --
• The opcode of the ST A instruction is 32H. It is fetched
204 f · C clc
INSIGHTS~MICROPROcES50~;;;R;S----------_....j rom the memory 41FFH -Opcode Fetch Maclnne Y
and the content from accumulator 1s written in s2 6Al:i. Address Mnemonics Opcode
Memory Write Machine Cycle ~
4200 6AH
4201 52H
DT I R
Clk
DTIR
ALE
Figure 4.16 Read cycle timing diagram for minimwm 1'KNh S-1 - -S-o
• A write cycle also begins with the assertion of ALE Mlffi<· -·-7__--1
the emission of the address. The M/ IO signal is DT 1 t r
r-
asserted to indicate a memo .
after sending th dd
ea ressinT
ry or I/0 operation. In
th
_;-~
data to be ·tt 1, e processor sends DEN- --------
,
----- - - wn en to the addressed location.
. .H T S O N M ~ -----=-- Figure 4.18 Memory read timing diagram Jor m
.
---.:::--
- - - - - - - -MIC--=-ROPR==:;;;;;ocessOR svsTEM
aximum mode
211
are various types of memory which can be .
'fhere . classified
4. Memory Write Timing Diagram for Maxi . groups: pnmary memory and secondary m
of 8086 ___ rnutn Mode .,,, rnalfl emory.
jJltO ,,. 0
prilllatY Memory
1- . the memory
It 1s .
used by microprocessor to execute
C lk
.,,..s
pro gra ... · The nucroprocessor can access only those items
.
ALE
that are stored in thi_s memory. Hence, all data and program
_ _ ....c..:..:.:..:..:..:._ _ _ Y.,_ ____l!'_•_c_t ! ' : ~ - - ~ ~ must be within primary memory prior to its executioQ
prirnary memory is much larger than processer memory that
ADD/STATrs BlIE S7 -S,
is included in the microprocessor chip.
T. . . . .
1
Y re ated functions such as STA, LDA
Miciio.~-
. .IIICROPiioc•SIOR svsTBI I"'
Eight J/P switch interfacing at 53H (01010011):
2732 (4K x 8): EPROM, address range should be .
ii, ooooH and additional 4K memory space shou~n at
available for future expansion. be
Latch
Step 2: Memory mapping table
Enable Memory Address
Ats A1i Au Au Au IA11 A, As A1 Ai; As ~ AJ A2 A1 Ao
Block
EPROM 13tart:OOOOH
Figure 4 24 N, . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
· on-unique d.'d End :OFFFH 0 0
a ress decoding I I I 1 1 1 1 1 1 1 1 1 1 l
RAM 13tart:2000H
If Ao is low and IOW . 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
End:
---
H is ow. Then latch gets enabled. 0 0 I I
ere A1-A7 is neglected . 27FFH I 1 1 1 1 1 1 1 1 1 1 11
enable the latch. that ts any even address
Examples:
liere, after placing EPROM, we need to reserve 4K x8
I.
Design an interfacing c· . rnernory for future expansion; hence starting address of
1rcu1t for foll 0 . RA.M comes to 2000H instead of 1000H.
i. 74LSI38· 3 t 0 8 D Wing problem.
_ • ecoder
220{ INSIGHTS ON MICROP_R_ ----- -
OCfSSoRS · - - - - -~ - -
The output from decoder Y1 (001) selects the EPROM and Step 1: Caku1ate the number of address pins.
(100) selects RAM. The address decoding circuit is di:
below. 4 8 chip requires 12 no. of address pins and 2Kx8 chip
require
KX. s ll no. of address pins. This can be calculated from
n = log (memory capacity in bytes)/ log (2)
+5V
Step 2. Memory mapping table
~
•
I }!ere,I tnuc
hen sends the data to be printed and required
E,. E2, E3 4K X 8 I .. ·dea
74LS 138 ". • I EPROM 1
nunan d for that.
".
I>•
3x 8 Active
High Decod er II co . of typical microprocessor to 1/0 devices such
RT, prmter etc ., all need 1/0 interface
for interfacing_ . . circuits which
I k
as in1 two types.
eyboard, C . parallel interface and senal interface.
•
Address [ areofma y
lines i
Ao . llel Interface
. ..,ac1•ng refers to a multiline channel, which is
4,8.1 Para llel mter
1
A Opara . .
f transmitting several bits of data simultaneously.
h This
.
■
A10
capable .
Bel mter facmg
. transfers n-bit data at
. t e same
. time,
.
Address i
means, para f wires. In parallel mterfacmg with
Ao
lines /
• using n
number o . /
-based system, microprocessor and mput o_utput
microprocess~r ted with multiline channel al!owmg a
. are mterconnec . . th
Fig.: Address decoding circuit devices . hi her data rate and hence maxuruzes e
system to achieve
d 'dth Before USBg ports became common, most personal ·
4.8 Input/Output Devices
computers
ban w1 .(PCs) had at least one parallel interface for connecting a
Input/output devices are the means through which printer using a parallel port.
microcomputer unit communicates with the outside world. 11te
between the I/0 devices and the microprocessor is maintained Data Transfer Modes of Parallel Interfacing
circuitry known as I/0 module. This circuitry includes the s , transmission of data ts
. use d. for
interfaces needed for I/0 devices as well as control functions Parallel . short
Thi distance
f rm ofwhere
data
. transter 18
the speed of information · critical. s ter0 peripheral
implement the I/0 transfers within the computer. 1/0 d ·
. . . f
communication 1s oun 1 d . n newer type of compu
. haracters per
usually are appeared as passive devices which take action
when instructed to do. The CPU monitors the status of the I
.
equipment with transfer speed O f t O one .mil1dion
. c and various
second. The equipment inclu d es pnn. ters, disk nves,
devices and selects them according to availability and need.
other forms of peripheral components. d
Consider the keyboard as input device and the steps
the key is pressed are
The information exchanged between a microprocessor an
d t and control
an 1/0 interface circuit consists of input or output . a a rocessor to
• Microprocessor detects the key change in status of ke
i.e., the key is pressed. information. The status information enables the nucrop eive data.
. the device and when it is rea dY then send or recr to cause
lltoIUtor
• It receives the encoded information Control infonnation is the command by microp"""'"', d~-
pressed key.
1/o device to lake some action. If the devke ope,ates a a,ticul"1
-r
speed s, then microprocessor can be used to select da top transfer
226 INSIGHTS ON IIIIICROPROCESSORS sPeect of operation of the device. The techniques use
- - - - - - - - - - - - : -::MIC:::RQPROCE~Mt:1!1SSOR&&
data between different speed devices and computer is lJ sffi ~
synchronizing. There are var~ous . ca ed
ways of synchronization
techniques which are inv_olved m parallel _data transfer such as
simple input and output, simple strobe I/0, single handshaking, illld
double handshaking.
Data-==><=====
Figure 4.29 Simple strobe J/O
1. Simple 1/0 The send 1·ng device outputs parallel data on the data lines,
To get digital data from a simple switch into and th en outputs STB .signal to. represent the valid data is
.
microprocessor; switch is connected on input port line froll'Ia present • In this technique, microprocessors
. need to wait
which port can be read. The data is always present ilnd until the device is ready for the operation and also known as
ready so that it can be read at any time. Similarly, to outp simple wait J/0.
data to a simple display device like LED, the input of L
buffer is connected on an output port pin. And output Single Handshaking
logic level required turning on the light. The LED is alw Handshaking is the method of synchronizing the actions of
there and ready so that data can be sent at any time. slow peripheral devices with that of high speed
microprocessor. It can have two transfer schemes:
Data.==x===
- - ----- - -----
indicate data has been read and peripheral can senct
next data, "I got tha t one, send me another". . heral then sends data and raises its 8TB .
•
Penp . 1me 1ow to
say "Here is some vahd data for you."
• Microprocessor sends or receives data when peripheral
is ready. Microprocessor then reads the data and drops its ACK
• to say "I have the data, thank you and .
Output handshake (peripheral from microprocessor): Jine ' ' 1 await
your request to send the next byte of data."
Microp rocessor outputs data to peripheral and asserts a
Outpu_t handshake (peripheral from microprocessor)'·
strobe (5TB) signal. I£ peripheral is ready, it answers back
with acknowledgement (ACK) signal to microprocessor. Micropro
. cessor sends a strobe (SIB) signal and data and
4. Double Handshaking . h eral sends acknowledgement (ACK) signal.
pertp
For data transfers where even more coordination is requir Programm able Peripheral Interface {PPI) - 8255A
between the sending system and the receiving system, The Intel 8255A is a general purpose programmable I/0
double handshake is used. It can have two transfer schemes.
. des1gn
device · ed for use with. Intel. microprocessors.
. . It has 24 I/0
Input handshake (peripheral to microprocessor): pins
. that can be grouped pnmanly m two 8-b1t. parallel ports: A
and B, with the remaining bits as port ~- The 8 b1~s of port C can be
Peripheral asserts strobe (5TB ) line low to ask recei use d asm· di·v1·dual bits or be grouped m two 4-bits ports: C. upper
device whether it is ready or not for data recepti (Cu) and c lower (CL)- The functions of_these ports are defined by
Receiving system raises its acknowledgement (ACK) · writing a control word in the control register.
high to indicate it is ready. Peripheral device then sends
byte of data and raises its strobe (5TB) line high.
microprocessor reads data, it drops its acknowledg
-
""""'{-- -Gll()
(ACK) line low and requests sending system to send n
byte of data.
srn~
ACK___)__,~
:x =
..,
Data-=
Figure 4.31 Double handshaking
• The peripheral asserts its 8TB "'""'
microprocessor "Are you ready?" u ___J
•
I
The microprocessor raises its ACK line hi h to say
am ready". g Figure 4.32 Internal block diagram of 825SA
230 MIOlc>PRocruoRS ---~ --
------------
INSIGHTS ON
The 8255A has the following main blocks:
Table 4.3 Port selection of 8255A
a. D ata bus buffer ,----
A1 Ao Selection
The 3-state bidirectional 8-bit buffer is used to interface th cs
,------
8255 A to the system data bus. Data is transnuttect e
0 0 0 Port A
received by the buffer upon execution . of mput
. Ot
or output ,-------
0 0 1 Port B
instructions by the CPU. Control words and status ,---
0 1 0 Porte
information are also transferred through the data bus buffer. r
b. Read,lwrite control logic 0 1 1 Control register
'
1 X X 8255A is not selected
The function of this block is to manage all of the intern.a) cllld:
external transfers of both data and control or status words. Group A and group B controls
accepts inputs from the CPU address and control buses
Funchona
. l configuration of each port is programmed by the
in tum, issues commands to both of the control groups.
system software · In essence, the CPU outputs a control word
• Chip select (CS): A "low" on this pin enables he 8255A. The control word contains information such as
communications between the 8255A and the CPU.
to t
"mode", "bit set", "bit reset ,, , etc. that uu
. ·h·a1·1ze the
functional configuration of the 8255A. Each of the control
• Read (RD ): A "low" on this input enables the 8255A blocks (group A and group B) accepts "commands" from the
send the data or status information to the CPU on read/write control logic, receives control word from the
data bus. In essence, it allows the CPU to read from internal data bus, and issues the proper commands to Its
8255A.
associated ports.
• Write (WR): A "low" on this input pin enables the • Control group A - Port A and port C upper (C7-C)
to write data or control words into the 8255A.
• • Control group B - Port B and port C lower (CJ-Co)
Reset (RESET): A "high" to this pin dears the con
register and sets all ports (A, B and q in the in The 8255A functions in two modes:
mode.
• Bit seVreset mode: The BSR mod e ts
· u sed to set or reset
• the bits in port C.
Ao and A1: These input signals control the selection
one of the three ports or the control word register. • J/0 m~e: The 1/0 mode is further divided into three
are connected to the least significant bits of the ad
bus. modes: mode O mode 1, and mo d e 2· In mode 0,. all
ports function , as simple 1/0 po ~ · M~el ~a bits
h
The .CS signal is the master chip select, and Ao and andshake mode whereby ports A and/or B use d hake
f
th .
rom port C as handshake s1gna ls· In the han s be
below. one of e l/O ports or the control register as gi
specify
rnocte, two types of 1/0 d a t a transfer cande 2
.tmplemented: status check and mterru
. pt· In mo
transfer'
port A can be set up for b 1.d.tree tional data n be
Uslllg
. handshake signals from port C and port 8 ca
set up either in mode O or mode 1.
---MICROPROCESIORsvinarr
The 8255A is a widely used, programmable, Parallel l/o
device. The features of 8255A are:
ro I word:
1D JD j D1l DoJ
It J/0 C0 nt
be programmed to transfer the data ,,
can . . -.nde ~jD
5 4 3 2
various conditions - from sunple 1/0 to mterrupt I/o 1 L.._Group~
1 =Input
0 = Output
The 8255A can operate in three 1/0 modes
mode 0, mode 1, and mode 2. Port A
1 = Input
8255 Control Word
0 =Output
When Ao and A1 pins have value 1, Mode Selection
00 =Mode0
addresses the control register which is the 8-bit register to wri 01 =Mode 1
specific content according to the port conditions although it c 1x = Mode 2
be read. The content of this register is called control word w
specifies an I/0 function for each port.
• 1 = I/O Mode
Q = BSRMode
The MSB (D7) of the control word tells which control
we are sending it, that is, it specifies either the I/0 function or
Figure 4.33 8255A co11/ro/ word fonnat for I/O mode
bit set reset function. If bit D7 = 1, bits 0 -0 determine 8
6 0
functions in various modes as shown in figure. If bit D7 = 0, SR control word:
operates in the bit set/ reset (BSR) mode. The BSR control
does not affect the functions of ports A and B. This control word, when written m
0
°
. con tr I register, seb or
resets ne bit at a time, as specified in Figure 434 ·
,...,..TSO. Moc,.,..oc,;,,,., -- -
MtcROPROCESSOR sm•• I"'
D7 D6 Ds D4 D3 D2 D1 00
outputs are latched
O ~R
, Inpu ts are not latched
6 d •fferent input/ output configurations are .
Set,,, 1 1 mode.
this 1 possible in
BSR Mode Reset,,, 0
BSR Mode (Bit Set/Reset)
Not Used 2.
Generally Set = 0 gsRm
0 de is concerned only with eight bits of port C
. .
hi
, w ch
can be set or reset by wntmg an appropriate control word in
000 = Bit 0 the control register. A control word with bit o " is
7 0
recognized as a BSR control word and it does not alter any
001 = Bit 1 previously transmitted control word with bit D7 " 1; thus the
If O operations of ports A and B are not affected by a BSR
0JO = Bit 2 control word. In the BSR mode, individual bits of port c can
be used for applications such as on/ off switch.
011 = Bit3
Mode 1 (Strobe Input/Output)
100 = Bit4
The functional configuration provides a means for
101 = Bit 5 transferring I/0 data to or from a specified port in
110 = Bit 6 conjunction with strobes or handshaking signals. In mode 1,
port A and port B use the lines of port C to generate or
111 = Bit 7 accept these handshaking signals.
Figure 4.34 8255A control word format for BSR mode Mode 1 basic functional definitions:
Operating Modes of the Intel 8255A • Two ports, port A and port B can operate in mode 1.
l. Mode O(Basic InpuVOutput) The 8-bit data ports (port A and port B) can be either
This functional conf . input or output. Both inputs and outputs are latched.
.
output operal!on igurahon
for each provides
f simple input
0 • The separate 3 bits from port C are used to provide
'handshaking" 1s• required·
. d t • . . the three ports. control and status for 8-bit data ports.
from a specified port. ' a a is simply written to or
Mode 2 (Strobe Bidirectional Bus J/0)
Mode O basic functional def' 't•
in1 10ns:
• Two 8-bit ports ( t' A
The functional configuration provides a means for
(port C Jowe :or and port B) and two 4-bit
r anL port C upper) can operate in mode
c~rnrnunicating
81
8
with a peripheral device or a structure on a
~gle -bit bus for both transmitting and receiving data
• Any port can be input or output (b1directional bus I/0). "Handshaking signals" are provided
to Itlaint · . · il r manner
236TINSIGHTS ON MICROPRoc ftounction
am proper bus flow discipline m a 5 ,m a
rnoct e 1. Interrupt generation and ena ble/d1sable
.
/ EssoRs
_ s are also available.
MICROPROCESSOR SYSTEM
Mode 2 basic functional definitions: . J· l ~ -3V to -25V
Sena.
• Only port A can operate in mode 2. O ~ +3V to +25V
• The 8-bit data port (port A) can be either input or para IIe I ·· 1 ~ +5V
output. Both inputs and outputs are latched. a~ov
• The 5 bits from port C are used to provide control and
status for 8-bit data port. Voltage 1o ss is not much a problem in serial communicafion.
• ~~ . 1 transmission requires less number of wires thM
4 .8.2 Serial Interface /Serial Data Transmission
parallel and so cheaper to transmit data.
Within a microcomputer, data is transferred in paralle~
because that is the fastest way to do it. For transferring data over • Crosstalk is less of an issue because there are fewer
long distances, however, parallel data transmission requires too conductors compared to that of parallel cables.
many wires. Therefore, data to be sent long distances is usual)y Many ICs and peripherals have serial interfaces.
converted from parallel form to serial form so that it can be sent on
a single wire or pair of wires. Serial data received from a distant Clock skew between different cables is not an issue.
source is converted to parallel form so that it can easily bf Serials can be clocked at higher data rate.
transferred on the microcomputer buses.
Serial cable_ can be longer than parallel.
Serial Data Transmission
• Cheaper to implement.
In a serial data transmission, the data are sent one bit at a
Serial data systems may be simplex, half-duplex, and full-
over the transmission channel. However, since most proc
process data in parallel, the transmitter needs to tr duplex. A simplex data line can transmit data only in one direction
incoming parallel data into serial data and the receiver needs to (a commercial radio station is an example). Half-duplex
the opposite. transmission means that the communication can take place in
either direction between two systems, but can only occur in one
Computer A
10010110 direction at a time (an example is a two-way radio system, where
Transmitter Computer B
one user always listens while the other talks). The term "full-
-
~
Receiver
duplex" means that each system can send and receive data at the
.J
same time (a normal phone conversation is an example). Serial
Figure 4.35 Serial transmission data can be
sent synchronously or asynchronously.
In case of serial transmi · d .
bit • sswn, ata 1s sent in a serial form
by bit. on a single line. Also, the cost of communica 1. Serial Synchronous Data Transmission
hardware 1s considerably reduced . . .
channel is required for the . I since only a smgle wtre rec • In serial synch ronous data transm1sszon,
. . • transmitted or
data IS
. . . sena bit transmission Serial eivect b d f data
transnuss10n is slow as compared t II . ·. trans . ase on a clock signal. At a specific rate 0
0
para el transnuss10n. mission th b. t ch dock
Puls I ' e transmitting device sends a data It a ea .
Advantages of serial data transfe e. n orct . • · device
lltust k er to mterpret the data correctly, the receiving .
r over parallel:
• Longer data transmission m· s . lltust knnow the start and end of each data unit. The transnutther
ena 1mode 1
eceive ow the number of data units to be trans ferre d and .t e
1•S1GHrs ON M1C,o,""'5soR5- -- - _ ·----- r lllust b boundanes.
. _______
------- -e synchronized with the data
- -MIC-ROPROCESSOR SYSTEM
239
Therefore there must be synchronization between the tr mmunication is used generally
~~ tw
'
and receiver. Usually one or more sync characters are lter
S1rfl
,won°usare co
co
nununicating to each other at a high
. .
When
speed
o
indicate the start of each synchronous data scream or frain used to
co·filPuters . is commurucatmg to the computer. 0r a
e of dat
d terJ11llla 1 .
uf{ere
Transmitter sends a large block of data characters a,
O b and disadvantages of
the other with no time between characters. Transmittingned aft.er vantages synchronous
sends data continuously to the receiving device. If the data 1ce t' M nication:
ornntU
ready to be transmitted, the line is held in marking conditio 8 not c . dvantage of synchronous data communicatio . h
lvfa!Il a . . n 1st e
. d.1ca te th e start of transm1ss10n,
m · · th e cransrrutter
· sends out n. To
. h spee • The synchronous commurucahons
d . require high- sr,ee d
more sync characters or a unique bit pattern called aone fl h1griphera 1s/ devices and a good-quality, high banctw·ctth 1
depending on the system being used. The receiving device w~ pe ·cation channel.
con1J1l!!Ill
for data, when it finds the sync characters or the flag then
. s The disadvantage includes the possible inaccuracy. Because
mterpreting the data which shifts the data following the
characters and converts them to parallel form so they can be whenar eceiver goes out of synchronization,
. loosing tracks of
in by a computer. . dividual characters begm and end, correction of errors
where ill
takes additional time. '
Clock
2. Serial Asynchronous Data Transmission
The receiving device does not need to be synchronized with
Transmitter
the transmitting device The transmitting device can send one or
Sync Sync
more data units when it is ready to send data. Each data urut must
be formatted i.e., must contain start and stop bits for indicating
Start
Time- beginning and the end of data unit. It also includes one parity bit
to identify odd or even parity of data. To send ASCII character, the
Figure 4.36 Synchronous sen·a1 transmission Jonnat
framing of data should contain:
·nt SJ:1cru:onous transmission has the advantage that the
1 start bit: Beginning of data
I ormation is accurately aligned to the received data allo
operation at much higher d t '
th . a a rates. It also has the advantage 7 or 8-bit character: Actual data transferred
e receiver cracks any clock drift h· h . .
d ue to temperature variation) Thew ic 1may. arise (for ms 1 parity bit: Parity
complex interfaces d . · pena ty 1s however a • 1 or 2 stop bits: End of data
· esign, and potentiall a
mterface to configure (since th y
options). ere are many hi h When no data is being sent, the signal line is in a con5tant
• g_ or marking state. The beginning of the data character is
Data transmission takes lac . ;"tard1catect by the line going low for 1-bit time and this bit is called a
adjacent characters. Howev ~ e_ Without any gap between
is a continuous stream 0 f her, ata is sent block by block. A bl oth t bit· The d ata bits. are then sent out on the hne · one after the.
er Where th 1 fi t Parity bit
fixed speed. We will f cd aracters or d a ta b·1t pattern coming a sh 0 1
u ct conta.
e east significant bit is sent out rs ·
. . Aft r the data
In a sync bit bit,nct In to check for errors m received data. e b"t
blocks of data and hence th pattern between any ~ a p · t I ast 1-
~ e data transm·1ss1on
. . synchroruzau.
--~ tilt\e to 1.d anty bit, the signal line is returned high for a _e b·t 1
I _ _ _ __
IGHTS ON IIIIICROPRocrsscis . .
1s
.- -- - - ·- - - - - teferrect entify the end of the character, this alwavs high 1 15
----to as a stop bit. Some older systems use 2 st op bits.
241
MICROPROCESSOR SYSTEM
□
Marlang
Asynchronous SYnchronous
Start and stop bits Sync cha.racte
character.
.
are sent with each sent with
character.
rs are
eac
h
-- -------~-
------ - - - - _- ~ - - Ert
-- ~MICROPROCESSOR SYST riii
o,. o. ..,,.,
1'r•••mlt
(P ➔ SI
Td) rra
·tter section
nsrn•
fhe tra
conver
nsmitter section accepts parallel data f
ts them into serial data.
ro111 CPU
anct
..,,.,
::
~
Re«I"• When output register is empty, the data is transferred &om
bD buffer to output register. Now the processor can again load
CP ._SJ
another data in buffer register.
lliiRDY If buffer register is empty, then TxRDY is goes high.
lie
SVNDIIT/
If output register is empty, then TxEMPTY goes high.
F" BIUr::Dl!T
tgure 4.38 Functional block diagram of 8251A-USART The clock signal TxC controls the rate at which the bits are
Read/Write Control Logic transmitted by the USART.
• The read/ write contr 11 . .
determines the fun ~ ogic mterfaces the 8251A with The clock frequency can be 1, 16 or 64 times the baud rate.
c mns of the 8251A
control word written. t ·t according to Receiver Section
m o I s control register
• It monitors the data flow. .
• The receiver section accepts serial data and converts them
• This section has three re ·sters into parallel data.
status register and data bgiufc and they are control regis
,er. • The receiver section is double buffered, i.e., it has an input
• The active low signals RD \YR register to receive serial data and convert to parallel, and a
used for read/wr·t . ' ' CS , and C/ D buffer register to hold the parallel data.
I e operations "th h
• -
When C/ D is high, the co
wi t ese three registers.
. When the RxD line goes low, the control logic assumes it as
writing control w d ntrol register is selected a start bit, waits for half a bit time, and samples the line
again.
- or or reading status word.
• When C/ D is l •
ow, the data b If the line is still low, then the input register accepts th e
read/write operation. uffer is selected following bits, forms a character and loads it into the buffer
• When the RESET is hi h .
register. '
• The clock input i
g , it forces 8251A .
mto the idle mode• The CPU reads the parallel data from the buffer regi 5ter.
.h s necessary fo
825 •
wit CPU and this clock d r IA for communication Wh_e n the input register loads a parallel data to buffer
transmission or the recept· oes not control either the serial register th Rx
ion rate. , e RDY line goes high.
• The cloc k signal
. -RxC controls the rate at w hich bits are
™~mns-oNMtcRoP-Ro-- - --
/ CESSORS rec·
----__:ived by the USART. __
--- - -------'72,s
- - MICROPROCESSOR svSTE•
/
• During asynchronous mode, the signal SYNDET/B 10
. 1 •s changing every 3 ns, then
will indicate the break in the data transmission. Rl<DEy If s1gna t
• During synchronous mode, the signal SYNDET/B 1 3
will indicate the reception of synchronous character. Rl<DET 13aud ra te == -10 = 10 x109= 3x1Q8:: 300 Mbct
MODEM Control
3ns
• The MODEM control unit allows to interface a Moo
Not\ 1 frame of data is coded with. 1 bit, then baud rate and bit rate
8251A and to establish data commurucat· E.M to
MODEM over telephone lines. ion thro ugh ares am e· When frame . Qf dllta ant coded With two or more b·ts 1 ,
then baud rate and bit llOt laRle.
• This unit takes care of handshake signals
interface. in Serial 1/0
4, 10 Standards
4.9 Bit and Baud rate The serial I/O technique is commonly used to interface
different peripheral terminals such as printers, modems with
. The difference between bit rate and baud rate is c I" -
microcomputers which are designed and manufactured by various
and mtertwining. Both are dependent and inter-related. omp icated
manufacturers. Therefore, a common understanding must exist,
• Bit rate is how many data bits are transmitted per second. among various manufacturing and user groups that can ensure
• :oaud rat_e i~ the number of times per second a signal in a_ compatibility among different equipment. The standard is defined
mmun1cations channel changes. as the understanding which is accepted in industry and by users. A
Bit rates measu th standard is normally defined by professional organizations such as
transmitt d . re ~ number of data bits (that is O's and 1' IEEE (Institute of Electrical and Electronics Engineers), EIA
e m one second 10 a co . .
2400 b'ts mmurucation channel. A figure ol (Electronic Industries Association) as a de jure standard. However,
1 per second means 2400 zeros
in one second, hence the abbreviation ,, or ~~es c~~ be transmitfe4' a widespread practice can become a de facto standard.
(for example letters o be bps. Ind1v1dual characteJ:1t
, r num rs) th t I In serial 1/0, data can be transmitted as either current or
are composed of several b"tI S.
a are a so referred to as bytat,
voltage. When data are transmitted with current signal such for
A baud rate is the numbe . teletype equipment, 20 mA (or 60 mA) current loops are used.
communications channel h r of hmes a signal in a
2 c anges state · When a teletype is marking or at logic 1, current flows; when it is
400 baud rate means that th h or vanes. For example, Z'::
· e c annel can h at logic O(space), the current flow is interrupted. The advantage of
times per second. The term ,, h c ange states up to 240fl, th
change from 0 to 1 or fro 1 c ange state" means that it can e current loop method is that signals are relatively noise-free and
are · b
m to O up to X (' h suita le for transmission over a distance.
per second. It also refers to th m t is case, 2400) timelll
as voltage, frequency or ph elactuaJ state of the connection, such . When data are transmitted with voltage signal, th ere are
, ase eveI). various st d . .
The main difference betw an ards which are explained in this section.
~e can transmit one bit, or sli htl~ ~ t w o is · t h at one change of 1. RS-232C
depends on the modulation tec~y more or less than one bit, that
. a I transmission of data is used as an eff"icten
Seri · t means..for
~=lly
and baud rate (baud per second) ha~t ~sed. So, the bit rate (bps) tr
24 --- - . this connection· anslllittin d · . . . the ex1st.lllg
te::~SfEM ~,
con..- . g igital information across long diS tances,
6 INSIGHTS ON MICROPRocrsso-;;--- - - - - . - ~ - - - - - - ·•u11un1catio l" r can be used to
the
1
RS-232C
tr ansfer information which saves a lot of hardware. RS-232c . Cable
MCl488 .
interface developed to standardize the interface between 1S d ii!) Transm11
2
. .
terminal equipment (DTE) and data commurucation equiPlllent <1ta
--9V
(DCE) employing serial binary data exchange. Modem and Other +J .4 V 9 V
o.2 v - + .
devices used to send serial data are call_ed data communic<1tion Receive J
equipment (DCE). The computers or terminals that are sending or Till l>CE
MCl489
receiving the data are called data terminal equipment (DTE). MCl488
Figure 4.40 Con nection of DTE and DCE through RS-232C interface
Figure 4.39 RS-232C DTE and DCE connector plugs MC1 4B8 line driver converts logic 1 to -9V, logic Oto +9V
RS-232C is the interface standard developed by electronic MC1 489 line receiver converts RS-232 to TTL
industries Association (EIA) in response to the need for the signat
Signa1 1ev els of RS-232 are not compatible
. with that
. of .the
and handshake standards between the DTE and DCE. RS-232C haa.c DTE and DCE which are 1TL signals for that !me dnver
following standardize features.
such as MCl488 and line receiver MC1489 are used.
• It uses 25 pins (DB - 25P) or 9 Pins (DE - 9P) standard w Table 4.3: RS-232C signals used in handshaking
9 pins standard does not use all signals i.e. data, cont:n4'
timing and ground. DE-9P DB-25P
• 1
It describes the voltage levels, impendence levels, rise Protective Ground
fall times, maximum bit rate and maximum capacitance 3 2 TxD
all signal lines. Transmitted Data
• 2 3 RxD Received Data
·It specifies that DTE connector should be male and
connector should be female.
7 4 RTS Re uest To Send ·
•
It can send data at 20kBd for a distance of ft.
• 50 8
The voltage level for RS-232 are: 5 CTS Clear To Send
4 20
9 22 RI
23 DSRD
MICROPROCESSOR SYSTEM
Data terminaJ ready {DTR ): 23
After the terminal power is turned on and terzninal runs J!S-4 " Jem with RS-232C is that it can only"'"'"'"
any I A .,,jot prob t 50 ft at its maximum rate of 20Kbd. u long~
self checks, it asserts data terminal ready (DTR) signal to tel) the for abou h b dr ·
modem that it is ready. data reJiably d the transmission rate as to • e al astically reduced
. es are use . al lines with a common sign ground. Another
Data set ready {DSR ): jjJ1 to opend si~
doe . improvement over RS-232C is RS-423A. The
whic h is
When the MODEM is powered up and ready to translllit or f)A standar f tures of RS-423 are:
daed ea . .
receive data, it will assert data set ready (DSR ) to the terillinaI. standat 5 standard specifies a low impedance smgle-ended .signal
Thi . .
Under manual control or terminal contro1✓ modem then dials up be sent ove r 50 ,Q coaxial cable
. and partially ternunated
the computer. If the computer is available, it will send back which can_ .
ece1vmgen d to prevent reflection.
specified tone. at the r
Voltage levels:
Request to send (RTS ):
• Logic High: -4V to -6V
When a terminal has a character ready to send, it will assert
• Logic Low: 4V to 6V
a request-to-send (RTS) signal to the modem.
It allows a maxi·mum data rate of 100 Kbd over 40 ft line or a
Data carrier detect (DCD ):
maxunum
. bau d rate of 1 J<bd over 4000 ft line.
The modem will then assert its data-carrier-detect (DC.ii + 12V
+SV
signal to the terminal to indicate that it has established conn
with the computer. MC3C8IA
driver
Clear to send (CTS ):
mtogic
When the modem is fully ready to receive data, it asserts 4500
clear-to-send (CTS) signal back to the terminal.
Ring indicator (RI): RS-423
interface
4l!OQ -=-
It indicates that a ring has occurred at modem. Deactiv
-12V ~MC3488
DTR _o r DSR breaks the connection but RJ works independent1f -::-
3--
DTR 1.e., a modem may activate RI signal even if DTR is not ac · reoeiv•
Transmitted data (TxDJ: Figure 4.41 MC3488 driver and MC3486 receiver
. usedfor RS-423A
The terminal then sends serial data characters to the mo interface
Received data (RxD): Rs-422A
18
Modem wilJ receive data from terminal through this line. It . a newer standard for serial data transfer. It specifies
. that
· a
Data signaJ rate detect (DSRD):
each sivn 1 . tw ad1·acent wires l.ll
libbo o«a Will be sent differentially over O . am lifier to
r. n cable or a twisted pair of wires uses differential pthat the
It is used for switching different baud rate. ~ect noi ,..._ . dard means
si""-J se. • ne term differential in this stan . ther than
1•slGtm()N MICRoPftac~- · · ·
o<1e1 Volt
betw
.
age is developed between two Sign
. al Imes ra
een signal line and ground as in RS-232C and
RS-4Z3A. Any
- --
MICROPROCESSORSvsTEM l2s1
. I 01se
. mduce
. d m. one signal line will be induced equ~i,
"'I}'
. II/O Standards
·electnca . 1 rme · A diffe,entIBI
n · s1gna
the other b line <eceiv.,.
. . !lfca,,,
uo f seria
responds only to th e vo ltage difference etween its. two Inputs so ar1s
. oil O 4 Comparison
. of serial J/0 standards
m
--r------
...,
cofllP Table 4. ---
. l that is induced equally on two mputs Will not 1
any noise
have vo tage
any effect on th e ou tput of the differential receiver. RS-232C RS-423A RS-422A1
100 Kbaud at 40 ft 10 Mbaud a
•' 1 Kbaud at 4000 ft 0 ft
I 0 ft 000 ft
100 Kbaud at
000 ft
--
+3 V to +15+4 Vto +6 V line> a line
Figure 4.42 MC3487 dn·ver and MC3486 receiver used for RS-422A in V
3 V to -15-4 V to -6 V a line > b line
RS-422A has foJiowing standardized features:
•
·-
Logic high is transmitted by making 'b' line more
than 'a' line.
•
Logic low is transmitted by making 'a' line more
than 'b' line.
o ingle
•
The voltage difference between the two lines must be
than 0.4V but less than 12V.
I··-': . . nded
input
• output
.II,.
The MC3487 driver provides a differential voltage of
2V. oise
• llUllunity
The center or common mode voltage on the lines
between -7V and +.7V.
KOhm>4KOhm >4KOhm
• I •. • •
Transmission rate is 10 MBd for 40 ft and 100 I<Bd for 2500
ft.
-- - - - ~SYSTEM 53
· - - - -MICROPROCEISO
. al ts
. a bus grant signal which indicates that
componen t 1•t 1s communicating with is said to be the slave• 'l"'l
'Ile
, rT pA
signsor h as indeed released control of its buses
fl...,
CPU with its bus control logic is normally the master, but Other fhe ·croproces t their high-impedance states.
specially designed components can gain control of the bus by ' ttie lJll . the buses a
sending a bus request to the CPU. After the curre~t bus cycle is bY pJacJ!lg . has a higher priority than the INTR or
OLD in~ut
completed the CPU will return a bus grant signal and the '[he I-I pt inputs.
component sending the request will become the master. r,rMiinterru
Taking control of the bus for a bus cycle is called cycle ste~ oata rra nsfer Scheme
Just like the bus control logic, a m~ster_ must be capa~l~ of pla~
addresses on the address bus and directing the bus activity dllling l
p~A t) mode o f data transfer:
bus cycle. The components capable of becoming masters - Block (bUCS. heme, the I/O device withdrawsd the DMA request
processors (and their bus ~ontrol . logic) . and _DMf\ c o ~ Jn thiS sc b tes have been transferre .
Sometimes a DMA controller IS associated with a single mterface, o~Y after all the data y
they are often designed to accommodate more than one interface.
aling technique:
This is a process where data is transferred between Cycle ste hi h b tes are divided into several parts and
peripherals directly without the involvement of scheme, t e Y · · b kt
Int f s . g every par t the control of buses 1s given ac o
microprocessor. This process employs the HOLD pin on
after trans ernnstolen b ack when MPU does not need it.
microprocessor. The external DMA controller sends a signal ~ MPU and later
HOLD pin to the microprocessor. The microprocessor co
the current operation and sends a signal on HLDA and stops
the buses. Once the DMA controller is done, it turns off the
Programma bl e OMA Controller - Intel 8257
_
,.....
1111
signal. and the microprocessor takes back control of the buses. CNTII
....,.
Basic DMA Operation
• DRQ,
...,.
temporarily disabled. logic
• OR02
A DMA controller temporarily borrows the address • 11111
data bus, and control bus from the microprocessor N ca CNTII IS1leR,
tr~sfers the q.ata bytes directly between an 1/0 port anll e.
series of memory locations. DRO,
•
The DMAtransfers.
memory transfer is also used to do high-speed m e ~ IS1leR,
•
Two control si_gnals are used to request and acknowled.,e a
DMA transfer m the microprocessor-based system.
•
~e HOLD signal is a bus request signal which asks the
microprocessor to release control of the buses after tllt
current bus cycle. Figure 4,43 Functional block diagram of DMA controller .
254
-----
INSIGHTS ON MICROPROCESSO'Rnsr-~-----------
¾d
It is a device
. . ti between 1/0 device
to transfer the data d1rec Y
sPeedtndell)ory Without through the CPU. So it performs a
~~
high-
ri
.
"-------- ansfer between memory and 1/0 device.
iOR
word transferred by DMA.
~ wooden block for
• A1
2• 4
01
shielding
active 10
• In Write transfer the data is transferred from J/0 d Ao
low
II
memory. decoder D, Output Lactch
Do (61 H)
• Verifica tion operations generate the DMA addresses wi Do EN iow
generating the DMA memory and I/O control signals. +Vee
• The 8257 has two eight bit registers called mode set
and status register.
MIC.~·- r
4oocks and a ROM block each of 4 KB starting at h·
----- -
ooa. [2064 Pous '11
and A 13 are used for RAMs and ROM
Address Decoding Circuit: bl
·t temal decoder), bit A14 and A are
1-; to ex
A12
15
RAM (4KB): f{ellc~, (as an P
seJeetton ble externa1 device and bit Ao to Au are given to
d wena ROM.
Base Address = 4000H use ~ A ~A's and o o
f~•• 0 l
= 4FFFH + 0001H Au
=S000H 2•4 01
active
b1gh
End Address = Base Address +(Number of locations in flCI decoder
10
RAM-1)
SFFFH
A12
= 5000H+0FFFH
=SFFFH
ROM (4KB)
0000
cs 6000H
RAM 2 (4KB) • , i 1 1 1 1
1 1 1 1 1 1 1 1
Base Address (SOOOH),! 0 1 O 1;
End Address (SFFFH): / 0 1 °0 1 f 0 0 0 0
0 0 0 0 0000 0,
Do
ROM (4KB)
I 1 1 1 1
1 1 1 1 1 1 1 1
Base Address (6000HJ4
1 1 0/
' Fig.: Address decoding circuit h
End Address (6FFFH): j 0 0 0 0
1 1 oi 0 0 0 0 0000 Present a complete plan to use 2 RAM chi P 8 of 16 KB
·-- ········• 1 1 1 1 . r} eac
With 8085 lll1croprocessor.
1 1 1 1 1 1 11 • [2065 Cha1tra
258
-·-
INSIGHTS ON MICR~tQlp;;;;R;;O;CE;:SSo:::-R::S::--------------
th
Let e starting address be 4000H
--------M-IC:::-:RO::::::PR;;;.OCE~SSORUt']ilUSYSTEII
-
RAMl (16KB)
Base Address = OOOOH
At
End Address = Base Address + (number of locations in l<B A15 3FFFH
RAM-1) 16
= OOOOH + (16 X 210 -l)D Ao RAMl
D
= ODDOH + (16384-l)D cs
= ODDDH + 16383D l" 2 OOOOH
O'PBuffer
=3FFFH Active ....................
A1
RAM2 (16 KB) High
~ D7
Base Address = End Address of RAM 1 +1 l)ecOder
= 3FFFH + OOO1H
=40DOH
End Address= 4OOOH + (16 X 210 -l)D ~ D7
~
= 7FFFH
At
RAM1(16KB) 7FFFH
A1SA14A13Au AuAwAeAe A1AeAe"4 AeAzAtAa
Base Address:(OOOOH)
I Tr · • •································································-- MEMW
ioioioo 0000 0000 oooe
End Address: (3FFFH)
j OjOj1 1 1111 1111 1 1 1- 4000H
RAM2 (16KB)
0
fotr.-fOVR,M
Jx 2
Ao
ff : opcode of MOV R, M
acti~ 2050
low +Vee
IO'M MiMii
>
Ri5
A15-A,
I
~ : 20➔
I I I
:
I
~
I I
1
I
:
I
AD,-AD,~-e~------f0---®i
Fig.: Address decoding circuit
5. Draw the bus timing dia am .
34H is executed. gr when the instruction
2060H : opcode of ADI [2067 Shrawan] : : :
2061H : 34H
Ti I T2 I T3 I T4 I T1 I T2 I T3
: : : ''
\ /
-V : ' WR j,r-+---+--:--_;__..;....-~,--~
ADrADo± ! 20~
, ,
:
· ....;I\. ;20H , 1'
A,s-A8~-e:
:
:
:
,
-1"C:/ Opcode ·······f./wj\
I
i
:
~ .
'-=.:/•••~
:
'
: : : : :
I
IO/M 1\-.. ~-~--4--...:--~-+----,~
ALE-hi ;
! / ~;
--; - I :
! !
; Fig.: Timing diagram
I
'
'
I
~-- . .'
.
:
t i
WR _f,- I
IOIM : :
T'-;:i-t-+-;__.i_;_JI'
2&2!~:::-:::-----F.~ig:·~:Timinuo d'1agram
: 262 INStGHTso N MICROPRoc=E_SS_O_R_S_ _ _ _ _ _ _ _ _ _ __
MICROPROCESSOR svsTEII
ForOUT0lH
_.___ - J!
......._ ....,
_--
~-OUT
T,
.. ,to,c-~,
T, T, T,
I
T, T, lltC, Cl,'() ...--;;;;---_
1
~
!f
I Ju,-,.,.1
T, T,
.... T, r-;- ~ ~· i
'°" 10.
I r--'-
r,:-- i
~ «
" ..... V
C ------
:c:
I "'" "-" o'" }- ~- --
fE D---{ 8--~ ) ~. .,: II
n
r\ \
\
n n - .,:
>< -r-
_L
i
~
--
J l
1111
~ n
I/
I I~· :c:
~J l l-\ I I Ill I ....._ ~ rr
R r i'
'\ I ~
►
I
::c
I >-c "-r" C
-
iiE
~
I,\
.:· t
;:>
I
I
I
I
7.
Draw the bus tinu•
.
d.
ng 1agram
Fig.: Timing diagram
lo\
J.,;
>-c
!
I
_l.
,. - ..__
I
►
:-- =-- C r-- "'
J\,{VI A, 05H
_AOJ20H
oursoH [20 72 Magh}
}IL1' Clocks
1'-States
,-, -- JnstrUctions
MVIA,05H;
7
7
7xl
7xl
..
_:__
- ADI, 20H;
oUTB0H;
HLT;
10
5
l0xl
Sxl
Total Clocks: 29
li1
J? If T = 1 micro second, time taken to execute the program =
29 micro seconds.
i ''", -, 10.
Draw the timing diagram of LXI D, 2465H. Calculate the
lf. ... - time required to execute this instruction if the crystal
. frequency is 6 MHz. [2073 Magh}
Assume that this instruction LXI 0, 2465H is located in
memory address COO0H.
C000H : opcode (LXI D)
C00lH : 65H
C002H :24H
The timing diagram of LXI D, 2465 H showing the flow of
address/ data at different T-states is shown below.
2061
INSIGHTS ON MICROPROCESSOR$
--
------ MICROPROCESSOR sVl'f&II
Opcode Fetch (M1)
Memory Read (M2) Memory Read <Mi)
CLK
ALE
RD
d
.
. strUctions while an 1/0 operation is in pro g
gress. The
t is a process of ata transfer whereby an exte al d .
i)lterruP . m ev1ce
5.1 Introduction eripheral can inform the processor that it is re d f
or a P . . a y or
Virtually all computers provide a mechanism b - - - - unication . and 1t requests attention. The response t
coJlll!l . . o an
other modules (I/ 0 , memory) may interrupt th y Which i)lterrupt request 1s directed or controlled by the microprocessor.
processing of the processor. Interrupt is signal send b e norinal
d · h Y an extern ..., _ Polling versus Interrupt
evI_ce to t e processor, to request the processor to """ 52
particular task or work. Table 5.1 lists the most co perform a The interrupt process allows the microprocessor to respond
interrupts. mmon classes
to external requests for attention or service on a demand basis and
Table 5.1: Classes of interrupts leaves the microprocessor free to perform other tasks. On the other
Programs hand, in the polled or status check 1/0, the microprocessor
Generated by some condition th t
result f • . a occurs as a remains in a loop doing nothing, until the device is ready for data
. o an mstruct10n execution, such
anthmetic overflow' diVISion
· · by zero attempt as transfer.
t
execute an illegal machin . ' . o
e instruction, and
reference outside a user's allowed
• Each time the device is given a command, for example
" move the read head to sector 42 of the floppy disk'' the device
memory space.
Timer driver has a choice as to how it finds out that the command
Generated by a timer withi h
perform certain functi n t e processor to has completed. The device drivers can either poll the device
ons on a regular basis. or they can use interrupts.
J/0 Generated by 1/0
co . an controller, to signal normal
mplehon of an operation or to . .
• Polling the device usually means reading its status register
every so often until the device's status changes to indicate
of error conditions. signal a vanety
that it has completed the request.
Hardware
Failure
Generated by a fail
memory par·t ure, such as power failure or • Polling means the CPU keeps checking a flag to indicate if
I Yerror. something happens.
~ terrupts are provided r·
processmg efficiency Fo
.
p unarily as a way to imp
• An interrupt driven device driver is one where the hardware
· r example device being controlled will cause a hardware interrupt to
slower than the , most external devices are mu
. processor. Su os occur whenever it needs to be serviced.
transferrmg data to . PP e that the processor .
d. . a printer usin
15cussed m the previous h
h .
g t e mstruction rvcle
• With interrupt, CPU is free to do other things, and when
• tify the
c apter Aft -✓ something happens, an interrupt is generated to no
processor must pause and . ·. er each write operation, th
Th 1 remam Idle ·1 CPU. So it means the CPU does not need to check the flag.
e ength of this pause m be unh the printer catches up,
even thousands of instr t~y on the order of many hundreds or
• • like picking up your phone every few seconds to
Polling is
uc Ion cycles th see 1·f ·ting for the
at do not involve memory. you have a call. Interrupts are like wai
Phone to ring.
270 INSIGHTS ON MICROPROC
ESSORS
INTERRUPT OPE ~I
• Interrupts win if processor has other work to do . which the routine polls each device Th
order Jll . . h h hi . . e processor
·
response time · not en·ti' ca1.
1s ctnd event ,,~ the startmg wit t e ghest priority de .
chec~ . vice. Once it
-;nes the source of the mterrupt it bran h
• Polling can be better if processor has to respond to deter., ..... · .
. routine for that device.
' c es to the
ASAP; may be used in device controller th an event service
dedicated secondary processor. at contains
Pollin
Advantages of interrupt over polling:
• Interrupts are used when we need the fastest
response t0
event.
. For. example, we need to generate a series. of an
usmg a timer. The timer generates an . PUises Microprocessor
interrupt h Device I Device 2 • • • • Device n
overflows and within 1 or 2 sec, the interrupt . w en it
. all service ro .
is c ed to generate the pulse. If poll' Utine INTRt---_.......,__ _ __.__ _ _ __j
d 1 mg were used the 1_ _ _ _ _...,
e ay would depend on how often the poll ' . , Figure 5.1: Polled interrupt
could delay response to several rnsecs Thimg_ is done and
times slower. · s IS thousanda
Here several eternal devices are connected to a single
• Interrupts are used to save power consum t· interrupt line (INTR) of the microprocessor. When INTR
battery powered applications the . p 10n. In many signal goes up, the processor saves the contents of PC and
I , rmcrocontroll •
s eep by stopping all the clocks and ~r IS put to other registers and then branches to an address defined by
consumption to a few micro am s reduc~g power the manufactures of the processor. The user can write a
the controller from sle p . Interrupts will awaken program at this address to find the source of the interrupt by
ep to consume
needed. Applications of thi h power only whe starting the polled from highest priority device.
s are and held d ·
TV/vCR remote control!ers. ev1ces such
5.3.2 Daisy chain (vectored) interrupt
• Interrupts can be a far more efficie
are used for program d b . nt way to code. Interrup In polled interrupt, the time required to poll each device
e uggmg. may exceed the time to service the device through software.
5.3 Interrupt Structures To improve this, the faster mechanism called vectored or
daisy chain interrupt is used. Here the devices are connected
A processor is usually .
· on the chip. The f
pms provide d wit
· h one or more interrupt in chain fashion. This configuration is governed by the
h . re ore a spe .al . . priority of the devices. The device with the highest priority
andle mterrupts from c1 mechanism is necessary tQ
interru t i- several devices th is placed first followed by the second highest priority device
P mes. There are main} at share one of these
polled interrupts and daisy h . y two ways of servicing interrupts: and so on. When INTR pin goes up, the processor saves its
c am (vectored) interrupts th
current status and then generates INT A signal to e
S.3.1 Polled Interrupts · th
higheSt priority device. If this device has generated e
Polled interrupts · · · ill ush
l are hand! d b interrupt, it will accept the INTA; otherwise it w__!'....
s ower than hardware . e Y using software and is ~ . JNTAis
g enera l (common) • Interrupts. Here the processor' has the TA to the next priority device until the
d . Interrupt s . accepted by the interrupting device.
ev1ces. TI1e priority f erv1ce routine (ISR) for all
rNSIGHTS o.
-- 0 the d ·
272 M - ev,ces is det&mined by tire
ICROPRocess~ -----
ssor loads the program counter with th
When INTA is accepted, the device provides a m '[he pro Ce e entry
. eans to the . of the interrupt-handler program that will res d
processor for findings the mterrupt address vect 1oeatton h pon to
or us· . terrupt that is, t e control is transferred t h
external hardware. The accepted device responds b U\g t}us in ' ot e
t-handler program.
a word on the data lines w hi ch becomes the vecto Y Placing i,nterruP
r add
with the help of any hardware through which the ress At this point, the PC and PSW relating to the interrupted
. . d . . processor
points to appropnate ev1ce service routine. Here no program have been saved on the system stack. However, m •
interrupt service routine need first that means appr!en~ra} addition, the contents o~ the processor registers need to be
ISR of the device will be called. Pnate saved, because these registers may be used by the interrupt-
handler. Typically, the interrupt handler will begin by
saving the contents of all registers on the stack. Now, the PC
Microprocessor
is updated to point to the beginning oi the interrupt service
routine.
----
5. 7 In terrupts in 8085 are Interrupts
Jiardw
The 8085 mterrupt process can be described as follows :
z. INs on the 8085 allow peripheral devices to interrupt
some P .
I. The interrupt process should be enabled using instr .
the main program for 1/ 0 operati~ns. ~en an interrupt
which sets the interrupt enable flip-flop. The instruu~~Ion Er 8085 completes the execution of instruction it is
occur 5,
resets the flip-flop and disables the interrupt process. c Ion DI currently executing and transfers the program control to an
2. When the microprocessor is executing a program ·t interrupt service routine that services the peripheral devices.
IN . . . ' I checks tlra Upon completion of the service routine, execution returns to
TR !me dunng the execut10n of each instruction at the nd -:"j:
2 the main program. These types of interrupts where MPU
state of last machine cycle. T.
PINs are used to receive interrupt requests are known as
3. If .the line INTR is high and the interrupt Is
· enabled
nucroprocessor completes the current instr t · ' hardware interrupts.
h . uc 10n, disab
t e interrup t enable flip-flop, and sends an in
software Interrupts
acknowledge signal ( INTA ).
The 8085 has eight software interrupts from RST Oto RST 7.
4. The program control is transferred to the . t The vector address for these interrupts can be calculated as
tin 1nerru~
rou e (JSR). Now the processor saves the follows.
address of the next instruction and the contents of reme· Interrupt number >< 8 = vector address
on the stack.
For example, 5 >< 8 = 40 = 28H
5. The ~rocessor services the interrupt usin interru t
routine. At the end of th b . g P Vector address for interrupt RST 5.5 is 0028H
. e su routine, the RET ins •
retrieves the m d Table 5.9 shows the vector addresses of all interrupts.
. t emory a dress where the program
rn errupted and continues the execution. Table 5.9: Vector addresses/or software interrupts
Types of8085 Interrupts
Instruction Hexcode Vector Address
The 8085 microprocessor h .
supports two types f . as multilevel interrupt sy RSTO C7H 0000H
. o interrupts· ha d .
interrupts. · r ware interrupts and so RSTl CFH 0008H
I. Software Interrupts RST2 D7H 0010H
8085 allows some s ecial . . RST3 DFH 0018H
program Aft p . instructions to interrupt the
· er executin th .
the execution of . g. ese instructions, 8085 c RST4 E7H 0020H
instruction I·t •
transfers the progr Is currently executing ~RST5
am control t • EFH 0028H
Upon completion of the se . o an interrupt service rou
rvice routine, execution returns ~RST6 F7H 0030H
280 RST7 FFH 0038H -
INSIGHTS ON MICROPRO CESSORS
~ ~ : : - - - - - - - - - - - - - -~
211
INTERRUPT OPERATIONS
pis general ly used for critical events such as
. EL rRA d emergency shut-off
Hardware Interrupts cllOJl f ilure an
Jl1ltfll power a TRAP interrupt.
The 8085 has five hardware interrupts. 0JJell s to clear .
Table S.10 8085 hardware interrupts sfltere are f:WO way nucroprocessor that is by giving low signal on
resetting 1) .
S.N. Interrupt Trigger Priority Maskable Vector 1. l l ~ . N (external signa ·
R£SETI .
Address . h TRAP acknowledge (internal signal).
1s1 •ving a h1g
1 TRAP Edge No 2. lly gi
and
Level ncf 7,5 . skable vectored interrupt. It has
"" 5 . terrupt is a ma d b
2 RST7.5 Edge 2nd Yes The RST 7. rn . I . ositive edge sensitive an can e
t priority t 15 P d d
3rd
the second highes uls~ that is input goes to high an none~
3 RST6.5 Level Yes
·ggered with a short p fl ·t recognize . d . It can be enabled with
4 RST 5.5 Level 4th Yes trt ·ntain high state un 1 1 t) and SIM (Set Interrupt
to mat El (Enable lnterrup 1.
5 INTR Level 5th Yes two
mstructions . .
his interrupt is tr1ggere '
d the program contro 1s
Mask). When t
When any of these PINs except INTR is active, the · transferred to location 003CH.
control circuit of 8085 produces a CALL to a predet
RST 7.5 can be disabled by
memory location. This memory location, where the service
starts is referred to as vector_ed location and such interrupts 1. Using DI instruction.
known as vectored interrupts. The INTR is not a ¥ 2. System or processor reset.
interrupt, it receives the address of ISR from the external devi
3. After reorganization of interrupt.
In 8085, all interrupts except TRAP are maskable.
logic signal is applied to a maskable interrupt input, the RST 6.5 and RST 5.5
interrupted only if that particular input is enabled. maskable vectored
interrupts can be enabled or disabled under program con The RST 6.5 and RST 5.5 both are h RST 5.5
. d · rity whereas t e
disabled, 8085 disables an interrupt request. The interrupt interrupts. The RST 6.5 has the thir pn~ ered that is input goes
non-maskable that means it is under program control. has the fourth priority. These are level trigg b bled with
. d · Itcan eena
to high and stay high until it is recogruze (Set Interrupt
TRAP
two instructions EI (Enable Interrupt) a nd SIM control is
M . tr1ggere
· d ' the program
This interrupt is a non-maskable vectored interrupt, ask). When RST 6 5 interrupt 1s . t rrupt is
unaffected by any mask or interrupt enable. TRAP has the .
transferred to location 0034H and when RST 65 : me002CH
priority and is edge and level triggered. This means that the triggered, the program control is trans ferred to location
must go high and remain high until it is acknowledged. It
They can be disabled by
be acknowledged again until it makes a transition from high flit
to high. This avoids false triggering caused by noise and tr l. By using DI or SIM instructions.
When this interrupt is triggered, the program control is tr 2.
System or processor reset.
to location 0024H without an external hardware or interrupt 3
· After reorganization of interrupt.
282 INSIGHTS ON MICROPROCESSORS
------------ - - - - - · - - -- -
-·-------=:ON5-r·3
- INTERRUPT OPERATI
t,le Jnterrupt)
61 (f:ita t·on sets the interrupt enable flip-flop. Thus
INTR
in5tfUC 1
file El R5T _5, RST 5.5 and I_NTR are enabled using EI
. is a maskable non-vectored m
The .INTR · terrupt. I 6
lowest pnon ty. It can be enabled by EI (E b t has th e ¢'f 7.S'. When any interrupt 1s acknowledged or system
• . . na le In
im,trucbon. It 1s a level triggered interrupt that . .
high and it is necessary to maintain high state
. --
un: terrupt)
~put goes to
it recoo-n;
j(IStructton- pt enable flip-flop resets and disables all
reset, interru
To enable interrupt m . further process it is
interrupts.to execute El instruction within interrupt service
A fter receiv ing INTA signal, it has to supp Iy th e address ofo•uZed.
IS
R. necessarY .
. It is 1-byte instruct10n and no flags are affected.
ft can be disabled by routJ.Ile.
1. By using DI or SIM instructions. DI (Disable Interrupt)
instruction resets interrupt enable flip-flop. Thus it
2· SyStem or processor reset.
1
~isables RST 7.5, RST 6.5, RST 5.5 and INTR interrupts. It is
3. After reorganization of interrupt. of 1-byte instruction and no flags are affected.
Theh followin g sequence of events occurs when INTR .
h.
1g . signal gates SIM (Set Interrupt Mask)
This instruction is used to set interrupt mask and to send
1. The 8085 checks the status of INTR . serial output. It transfers the content of accumulator to
execution of each instruction. signal dur.qag interrupt control logic and serial 1/0 ports. Thus it is
2. ~f INTR signal is high, then 8085 . necessary to load appropriate contents in the accumulator
rnstruction and sends a t· 1 . complete Its cun.r before execution of SIM instruction. It is of 1-byte instruction
c ive ow interrupt kn
signal INTA . . ac owledp- and no flags are affected. The format of SIM instruction is
, if the mterrupt is enabled.
shown in figure below.
3. In response to INTA .
instr . signal, external logic plllC!lll • D7 D6 D5 D4 03 D2 D1 Do
uchon opcode on th d
byte instruct' . ~ ata bus. In the case of SOD SDE XXX R7.5 MSE M7.5 M6.5 M5.5
ion, additional ·
machine cycles mterrupt acknow
are generated b th
additional bytes . t Y e 8085 to trans
4 . mo the microprocessor. Serial Don't 1 = Reset I = Mask I = Mask I = Mask
Output Care RST 7.5 RST 7.5 RST 6.5 RST 5.5
· On receiving the . Data
of next instrucfmstruction, the 8085 save the ad
·
mstruction. IOn on stack and execute
1 = Serial Data Enable Mask Set Enable
8085 Interrupt Instructions
. O= Serial Data Disable I = Masking 1s Enabled
0 = Masking is Disabled
Maskable interru t .
F",gure 5.11 SIM instruction format
or unmasked using pr:grs are enabled or disabled that is
used for am control Th Actually ' SIM does the following
. three tasks:
SIM an program control in 8085 : ere are four ins
d RIM. rrucroprocessor namely EI, 1· Masks th ·
b·t . e interrupts, bits O to bit 2 set/reset the mask
1 s in Inter
m k rupt mask register. Bit O masks RST 5. 5, b't
1 1
en:: :s R~T 6.5 and bit 3 masks RST 7.5. Bit 3
284 rNSK;HTS oN M1ci.o,ROCESSORS
- -- - ------- 1 I disables the masking control of bits O- 2.
-- - ---~·---- INTERRIJPTOPE1'J'1-T
-" serial input of data; bit 7 is used for 5 . 1
perfor "~ ena
4- pata Jnput.
Resets RST 7.5, bit 4 is used to reset it whether RST 7
2.
is masked or not. This JS mainly used to overwrite RsS rupts in 8086
C • h
wit out serving 1t.
7 .::>
. . T 111ter interrupt can come from any one of three sources.
Implements serial I/0. If bit 6 = 1 is used to enab 80 86
All t rnal signal applied to NMI pin or to INTR pin, and
3.
serial I/ 0 and bit 7 is used to transmit serial out le ()Ile 1. anexe .
d to as hardware interrupts. Another source of an
5
da ta bit. put are ~~~. ecution of the interrupt . . . and 1s. referred to
instruction
RIM (Read Interrupt Mask) if!ter! upt 1s ex
•nterrupt. The third source of interrupt is some error
3.
The RIM instruction loads the status of the interrupt m k as 5oftware
.. i roduced dunng
. .
the execution .
of an instruction.
t~e pending interrupts and the contents of serial input ~: ' cond1t10!1S P
The 8086 interrupt process can be described as follows:
lme, SID,_ mto accumulator. Thus it is possible to monitor th
At the end of each instruction cycle, the 8086 checks to see if
status of mterrupt 1:'ask, p~nd~g interr~pts and serial inpu
The format of RIM mstructJon JS shown m figure below. any interrupts have been requested.
D3 Dz DI Do 1f there is any interrupt, the 8086 pushes the flag register on
D1 D6 Ds D..
SID 17.5 16.5 15.5 IE M7.5 M6.5 M5.5 the stack.
The 8086 disables INTR input by clearing the interrupt flag
l PeLing
l
I =Mask
l (IF) and resets the trap flag (IF).
serial Status of 0 =Unmask l=Mask The contents of current code segment register and
Input Data O=U nmask
RST 6.5 RST 7.5
RST5. 5 instruction pointer are pushed on the stack.
Pendmg I =Mask
Status
RST of 0 -- Unmask Then, the program control is transferred to interrupt service
Pendmg 5
5 · lntemJpt RST 6.5
Status of Enable Flag
routine. An IRET . instrUction at the end of ISR returnS
RST 7.5 I = Enabled execution to the main program by retrieving the contents
0 = Disabled
which were pushed on the stack before.
Interrupt Service Routine
Figure 5.11 RIM instruction format
Push Registers
Actually, RIM does the following four tasks: Main Line Push Flags
Program ClearlF
1. Checks whether RST 5.5, RST 6 5 an ClearTF
;;::sked o, not bit Oto bit 2 show fue ,u';,!';.;! Push CS
Push IP
mask status of interrupts RST 5 5 RST 6 5 d g Fetch ISR Address
7.5. logic 1 m
· d.JCates the interrupt is masked.
· ' • an
2. Checks the
shows wheth ·
sta:s i~t~r\upts are enabled or not; bit
indicates that the i~te1rrn errutpt enable flip flop. Logk Pop IP
up s are enabled. Pop CS
Pop Flags
3. Checks whether RST 5 5 RST Pop Registers
interrupts are e d" · ' . 6.5, and RST 1RET
status of pend _P n_ mg or not; bit 4 to bit 6 show
7.5. Logic 1 ind:!tte~r~pts RST 5.5, RST 6.5, and
es t e mterrupt is pending. Figure 5.12 8086 interrupt response
--;;;-;;--r~ ----- ---------,N-T-ER_R_U-:PT::-:0::P:;;ERA~TIMON~S12287
286 INSIGHTS ON MICROPROCE~SS;O~RS~-----------'4
from 00000H to 003FFH. These are 2 byt
ss range 5 e
addre . IP is loaded from (type x 04H) and CS is loaded
8086 Interrupt Types i11struct1ons-
the next address given by (type x 04H + 02H). Some
There are two types of Interrupts in 8086. They are: fro11 1 ftware interrupts are:
i!XIJ'.'ortant so .
1. Hardware Interrupts (External Interrupts) . Divide by Zero Interrupt
• Type 0 .
Hardware interrupts
. are those interrupts which are caused W}len the quotient fro~ _either a DIV . or IDIV
y any peripheral
b ifi d · device by sending a signal thro h . struction is too large to fit Ill the result register; 8086
ug, a
spec e pm to the microprocessor. There are two hard
· t • . Ware :terrupt Types will automatically execute type o
m errupts m 8086 nucroprocessor:
interrupt.
i. NMI (Non-Maskable . Interrupt) - It is a single pmnon-
·
mas~able hard~are mterrupt which cannot be disabled Type 1 : Single ~tep Interrupt
It . 1s the highest priority interrupt in 8086 The type 1 interrupt is the single step trap. In the single
nucroprocessor. After its execution, this mterru~
· step mode, system will execute one instruction and wait
generates
. a TYPE 2 interrupt · IP is loaded from wo for further direction from user. Then user can examine
locat10n 00008H and CS is ,loaded from the the contents of registers and memory locations and if
locat10n 0000AH. they are correct, user can tell the system to execute the
ii. INTR (Interrupt Request) - It provides a s· next instruction. This. feature is useful for" debugging
~1terrupt request and is activated by I/0 port. assembly language programs.
~terrupt .can be masked or delayed. It is a I
triggered mterrupt. It can receive any interrupt type Type 2 : Non-Maskable Interrupt (NMI)
•
the :alue of IP and CS will change on the interrupt , As the name .suggests, this !"terrupt cannot be disabled
received. The INTA is the response pin for I by any software instruction. This interrupt is activated
request. by low to high transition on 8086 NMI input pin. In
_J Edge Triggered Input response, 8086 will do a type 2 interrupt.
NMI
=_r- Level Triggered Input • Type 3 : Breakpoint Interrupt (INT 3)
The type 3 interrupt is used to implement break point
INTR
function in the system. The type 3 interrupt is produc~d
INTA Response to INTR Input by execution of the INT 3 mstruction. Break pomt
8086 function is often used as a debugging aid in cases whe:
F igure
" single stepping provides more detail than wanteth ·
5.13 8086 hardware interrupts . . th tem executes e
2. Wh en we msert a breakpomt, e sys the
Software Interru p ts (In ternal Interrupts) instructions up to the breakpoint, and then goes to e
· t procedure w
These are instructions that ar . b reakpoint procedure. In the brea k P0111
to generate interrupt Th e mserted within the pro • uister contents'
can write a program to display . reo-that J.5 . requ ired
8086 microprocessor s~ ~re are ~56 software interrupts
type where type . e mstructions are of the format memory contents and other infortnati on·nsert as u-· _,.ny
1
ranges from OOH to FFH. The sta . to debug our program. We can
......._ breakpoints as we want in our program.
288 INSIGHTS ON MICROPR~O - - - - - - - --
. CESSORS
- - - - --
------------------ - - - - - - INTERRUPTOPERAT!oNS
e to type 4) are dedicated to
, types (typ O .
t five d" •de-by-zero interrupt, the smgle-
1oweS s the 1v1
'fJ1e ts such a k ble interrupt, the breakpoint
• Type 4 : Overflow Interrupt (INT 0) . terruP on-mas a
The type 4 interrupt is used to check o.verflow condition s.f~ Jicilltei1lrruPd t'thetheovernfl Ow. mterrup
. t Interrupt types 5 to 31 are
·
omplex microprocessors. The
. ed arithmetic operation. m the .system. The ,ter t art e in more c
after any sign iJ11erfl.lP' 111tel for us 32 to 255 are available for us to use
8086 overflow flag (OF), will be se~ if the signed resu1t ed by t types from
of an arithmetic operation on two s1~ed _n umbers is too ,e¢"' 224 jr\terrup m· terrupts. .
large to be represented in the destination register or ~rr·ner dware or software
for ha!
memory location.
. IVT structure (organization)
. "ti"ze the 8086 interrupts as follows: Figure 5.14, .
W e canpnon 3FFH Type 255 Pomter:
Table 5.5: 8086 interrupt priority (Available)
3FCHL--~_:_____;---i
Interrupt Priority
l
NMI (Available)
INTR 084H Type 32 Pointer:
Lowest (Available)
Single Step
osoHL--.2.----:-.---7
0?FH Type 31 Pointer:
Interrupt Vector Table (IVT) (Reserved)
.The interrupt vector table is a feature of the Intel 8086 familr
of microprocessors. An interrupt vector is a 4-byte number stored ia Reserved Interrupt
the first 1024 bytes of the memory (00000H - 003FFH). There art Pointers (27)
Type 5 Pointer:
256 different interrupt vectors. Each vector contains the address c,t. (Reserved)
an interrupt service routine. Each vector contains a value for 014H L---T.;._ype_4_P~o--:-in-:te-r:-:- 7
and CS that forms the address of the interrupt service routine.
(Overflow)
first two bytes contain the IP, and the last two bytes contain the
Thus, in terrupt vector table (IVT) is a 1024 bytes sized table 0l0H Type 3 Pointe~:
l-Byte Instruction
contains the addresses of interrupt service routine. The purpose
the IVT is to hold the vectors that redirect the microprocessor Dedicaed Interrupt
Pointers (S)
0OCH L__ Type 2 Pointer:
~-l
_J(~B~re~ak~p~o~in==:t:)
the right place when an interrupt arrives. Non-maskable
The figure below shows the organization of interrupt V 008HL---:T;ype.::::.=.~1EP~o:nin;te;r:--"J
table. The iriterrupt number is used as an index into the table to Single-Step
the address of the interrupt service routine. When the
CS Base Address
004H
··
L-_:~~~-7Type 0 Pointer:
responds to a particular type interrupt, it automatically multi · ..... ···························· Divide Error - - -
the type by 4 to produce the desired address in the interrupt V lP Offset
table. It then goes to that address in the table to get' the startillll 000H i..i......----16 Bits-
address of the interrupt service routine.
111tc1rupt controller (PIC) is used. The PIC includes a status register, "•
~
a priority comparator, and a priority encoder. "•
Ills
1....---...,.Jr--~
~ ---~1--A
_D_,,_0 _ _ _ _ _ __ ; - - - - - ~ IRo
Interrupt
Microprocessor AD Data Bus! PJC Inputs c,.sCADE
SUFFER
I~ cis,
cis,--,..---
coMPflRATOR
----·--------
- - - - - - - - - - - -,-NT_E_R_RU_P_T-::0-=PE:::RA:;;;TIO;;NMAS
Chapter-I
the corresponding bit in the IRR w ill be set. The content of this
regis ter can be read to know the status of pending interrupts.
Common Resources
RAM Memory
Plotter
High Speed Printer
Figure 6.1: Organization of multiprocessing system
294 INSIGHTS ON MICROPROCESSORS
'--------- - - -A
-D-VA
- NC--=Eo::-:T=.0;.;PICS;;;.12211
wbacJ.<s:
pra d f the system is limited by the cycle time because
Here, the processors can communicate with each other fhe spee o ferences must pass through the common bus.
through memory. The CPUs can directly exchange signals as all memory re
mdicated by dotted line. The organization of multiprocessor M1dtiport Memory .
and I/ 0 module has dedicated path to each
system can be divided into three types. 2, Ssor
:Each procemodule this system has mort; performance and
1. Time Shared or Common Bus memory •ty than earlier· one. F or th'1s syst em, 1t
· 1s
· poss1"ble to
comP
nfi 1ex1
ure portions of memory as private. to one or more
Memory unit
~PU; and/or I/0 modules. This feature allows increasing
•ty against unauthorized access, and the storage of
secun
recovery routines in areas of memory not susceptible to
modification by other processors.
IOP2
Memory
Figure 6.2: Time shared system modules
. ----
Figure 6.6: SISD
Process 1 CPl/ J •· Examples: Uniprocessors such as older generation
, ,. CPU 1 ~ :ceu 1 mainframes, minicomputers and workstations, most modem
Process 2
; CPU 1 .: ; CPI/ 1
- .,
•
day PCs.
2. Single Instruction, Multiple Data (SIMD)
Figure 6. 5: Pseudo-parallelism
Single machine instructions controls the simultaneous
For example, computer b .
printing on a printer while ~an . e readmg from a disk m execution of a number of processing elements on a lockstep
m ultiprogramming system, the ; g ~ user program. In ll basis. Each processing element has an associated data
program, running each switches from program t9 memory, so that each instruction is executed on a different
the CPU is runnin nlprogram for a fraction of second. Alth-...a.
CP g o y one program t . ~ set of data by the different processors.
U speed is very high so it c a any mstant of time. At
second. It gives user an ill a~ work on several programs in•
processes are being
. .
usmn of parallelism i e
processed at th . · .,
sevaw:
switching back and forth of th e same time. This rapkf
illusion of parallelism and is t e CPU between programs gives •
ermed as pseudo-parallelism. LM: Local Memory
6.3 Flynn 's Classification
There are different ways to 1 . -
of the more widely used cla;sif' ~ assifr parallel computers. cit
icahons, muse since 1966, is callld
Figure 6. 7: SIMD
298 INSIGHTS ON MICROPROCESSORS
Examples:
Array Processors: Connection Machine CM-2, MasP
MP-1 & MP-2, ILLIAC IV ar
Vector Processors: IBM 9000, Cray X-MP, Y-MP & c
90
Fujitsu VP, NEC SX-2, Hitachi 5820, ETAlO '
Most modem computers, particularly those with graphi
processor units (CPUs) employ SIMD instructions ~ I
-----
300 INSIG HTS ON MICROPROCES:;.SO~RS;;;-- - - - - - - -- - -- - e actvant mpi er and processor designers tS to 1den a
-----.. . age of as h . • ~-"- are
------ muc ILP as possible. Ordinary progrcu,..,
-- 3~
ADVANCED TOPICS
nning code on a 2-
if we are ru d
xatrtple, . arallel environment an
-111ple e " " & "b") 1Il a P. CPU "a" to do
f.S 3 s1 (CplJs a " ·tis possible tote11
t\ p1cal l\' wri tten under • a seq uential execution
. model wh ere r systelll "A" and "B , • 'B" simultaneously, thereby
,,.;:esSo do tasl<s " to do task
f
m,truc tion.; e ecute one a ter tl1 e other and m the order specif
1e d r.,.. hto
1
"b
b:; the programmer. lLP allows the_compil_e r and e processor to
th iewis d cPlJ e execution.
i i, "A" 311 .., time of th d. tributed (parallelized)
oYerl.ip the execution of multiple instructions or even to change tas~ the ru•· h ·zes the is
the order in vvhich instructions are executed. .,~ciJlg llelisrn ernp as1 pposed to the data (data
~ d para hr ds) as o .
'f)u'ea ssing (i.e., t ea , here on a contmuum
How much ILP exists in programs is very application f the proce ams fall somew
s penfic. In certain fields, such as graphics and scientific computing nature o ) Most real progr d data parallelism.
the a mo unt can be very large. However, workloads such as aUelisJll . arallelisrn an
par een thread p . tes task parallelism:
cryptography exhibit much less parallelism. tietw d below illustra
The pseudoco e
Micro-architectural techniques that are used to exploit 11.P
program:
includ e:
• Instruction pipelining where the execution of multip)e
if CPU="a" then
instructions can be partially overlapped.
do task "A"
• Superscalar execution, VLIW, and the closely relal!INI
Explicitly Parallel Instruction Computing concepts,. fa
else if CPU="b" then
which multiple execution units are used to ~ do task "B"
multiple instructions in parallel. end if
Thread-Level Parallelism
TI1read parallelism (also known as task parallelism, end program
parallelism and control parallelism) is a form of parallelization The goal of the program is to do some n et total task ("A+Bn).
computer code across multiple processors If we write the code as above and launch it on a 2-pllrocessor
en vironments. Thread parallelism focuses on system, then the runtime environment w1·11 execute it as fo ows.
execution processes (threads) across different parallel co
n odes. It contrasts to data parallelism as another fonil • In an SPMD system, both CPUs will execute the code.
parallelism.
• In a parallel environment, b oth w1·n have access to the
It w as later recognized that finer-grain parallelism same data.
w ith a single program. A single program might have
• The "if" clause differentiates between the CPU's. CPU
threads (or functions) that could be executed separately
parallel. Some of the earliest examples of this "a" will read true on the "if" and CPU "b" will read true
implemented input/output processing such as direct on the "else if", thus having their own task.
access as a separate thread from the computation thread. A • Now, both CPU's execute separate code blocks
g eneral approach to this technology was introduced in the simultaneously, performing different tasks
w hen systems were designed to run multiple computation simultaneously.
in parallel. This technology is known as multi-threading (MT)
Code executed by CPU "a":
program:
ADVANCED TOPICS
d on the res ult of the previous
. ration depen s 11 I As the size of a problem
. 5iJlce each i;rforlJled in par;e~~m available usually does
auo!l· arinot be p f data-para
do task "A" itd theY c mount o ,
oJle, r the a
bigge'
oets
end program 0
veil, l rsrn tr l
Code executed by CPU "b": asi I paral e I . f one or more cen a
program:
sLeve . the use o The
proces • el parallelism i~ sin le computer system.
process-I~ (CPUs) within a g pport more than one
do task "B" . units .. f a system to su Th
roeessing t the ability o k between them. ere
p a)so refers o b'lity to allocate tas s d f "tion of
end program teflll or and/ or the a i . basic theme, and the e rm
proeess variations on this ry with context, mostly as a
This concept can now be generalized to any number ef
are
manY r can va
I vel paralle ism . d (
d"
ltiple cores on one ie,
processors. process e CPU are define mu tern
function of how s k ge multiple packages in one sys
Data Parallelism . in one pac a '
multiple d,es
Data parallelism is parallelism inherent in program I ~
which focuses on distributing the data across different compu ·
unit, etc.). . on who ou talk to. In the past, a
This varies, depending up y inanlar execution
nodes to be processed in parallel. Parallelizing loops often leads P • g Unit) was a S---o-
similar (not necessarily identical) operation sequences or twrtctl"-Fit:
CPU (Central rocessm lti le CPUs were
for a computer. Then, mu p
being performed on elements of a large data structure. ~ component . d Then individual CPUs were subdivided
scientific and engineering applications exhibit data parallelism. incorporated into a no e. ' . . unit CPUs
into multiple "cores", each being a unique execution . .
A loop-carried dependency is the dependence of a 11M- . •0·.-- "1th multiple cores are sometimes called "sockets". The result 18 a
iteration on the output of one or more previous iterations. ~
node with multiple CPUs, each containing multiple cores.
carried dependencies prevent the parallelization of loops.
example, consider the following pseudocode that compu.- • During the past 20+ years, the trends indicated by ever
first few Fibonacci numbers: faster networks, distributed systems, and multi-processor
PREV1 :=O computer architectures (even at the desktop level) clearly
PREV2 := 1 show that parallelism is the future of computing.
do: ' ~ this same time period, there has been a greater than lOOOx
CUR := PREVl + PREV2 increase in supercomputer performance, with no end
currently in sight.
PREV1 := PREV2 65
PREV2 :=CUR ' ~~~er-p~ocess Communication, Resource
ocataon, and Deadlock
while (CUR < 10)
IQter-Pro ---<...;;:.::.::._:::~~~~-----------
This loop cannot be parallelized because CUR depends Cid.·" '"·""r•·• cess Conununication
itself (PREV2) and PREVl, which are computed in each loop llletJi0In coin.Putin ·
., ds for th g, inter-process communication (IPC) is a set of
'"ore e exchang f d .
304 INSIGHTS ON MICROPROCESSORS Processe p e O ata among multiple tbn=ads m one or
s. rocesses may be running on one or more
ADVANOEDTOl'a -
·1 cate certain resources for it to be able to run
computers connected by a network IPC methods are d " . uter to a 10 ·
the cornP could be access to a section of the computer's
methods for message passing, synchronization sh
and remote procedure calls (RPC). The method' of
vary based on the bandwidth and latency of
:;~d
IV1ded into
memory,
used rnay
sueh resources
d t in a device interface buffer, one or more files, or the
emory, a a . .
lil . d rnount of processing power.
between the threads, and the type of data being co communication require a
Th nunurucated A cornputer with a single processor can only perform one
ere are several reasons for providin a . s at a time regardless of the amount of programs loaded by
aJlows process cooperation: g n environment that proces '
the user (or initiated on start-up). Computers using single
• Information sharing rocessors appear to be running multiple programs at once
• Speedup ~ecause the processor quickly alternates between programs,
• Modularity processing what is needed in very small amount of time. This
• Convenience process is known as multitasking or time slidng. The time
• Privilege separation allocation is automatic, however higher or lower priority may be
given to certain processes, essentially giving high priority
. IPC may also be referred to as in
and inter-application communicati ter-thread communication programs more/bigger slices of the processor's time.
on.
On a computer with multiple processors, different processes
The combination of IPC with
the foundation for address. space . d the address space· concept is can be allocated to different processors so that the computer can
Th . m ependence/isolation truly multitask. Some programs, such as Adobe Photoshop, which
e single operatin . can require intense processing power, have been coded so that they
resources in a m lti" g s_ystem controls the use of
. u processing • system are able to run on more than one processor at once, thus running
multiple jobs or process may envrronment.
b . In thi s system,
more quickly and efficiently. ·
responsibility of . e active at one tirn
h operating syst e. The
sc e~ule the execution and to all:m or system software is to Deadlock
multiprocessor operating cate resources. The functio f A process requests resources; if the resources are. ~ot
system are: ns o
available at that time, the process enters a wait state. Waiting
• An interface betwee processes may never again change state, because the resour~es ti:1ey
• R n users and machin
esource man agement e ~ave requested are held by other waiting processes. This situation
• Memory management 18called
p a deadlock. • reasonable order.
• Prevent deadlocks rocesses need access to resources 1Il 8 t
•• Abnormal program termination Suppose a process holds resource A and requests
same time another process holds B and requests A;
~:i. -;
Process scheduling
blocked and remain in deadlock. .
• Managers security
.. A set of processes is deadlocked if each process in theA~..:
· the set can ...........
Resource Allocation
In computing
application t0 b e run' on
resource
th allocation is
· necessary for any
waiting for an event that only another process 1Il
Usually the event is release of a currently held
the processes can run, release resources and then be a
res<>=~
None of
---------~-- -
. w ill be countede system. When the user opens any
program, this
as a process, an d therefore, requires
r•
mle,-n,p1. Fo, example, when a key ;, pcesse,J on a compuler of Cl!, are ~ ';;", lhey can become quite lost. Examples
key boacd, a hacdwace U>tenupt;, genecated, Wltich Ulvokel
th Pton,pt. e ND( shells and the Windows Commanc1
_ , ke~ d,;vec. Aftec the drive, ha, Brushed In contrast
ON MICROPRocfssoii, devi ' a GDJ Prov· ct ·
1
ce
Perform_(sach as es
a lll.ouse) is a visual
d environment when, a
ike - use to navigate the system and
CLJs Where performm
become slow and error-prone (such as when very Ion
commands are to be entered), GUis present the user . g
. ~~
• Processor management - Allocates the processor (CPU)
widgets that trigger some of the operating systein's to a process and de-allocates the processor when it is no
commands, reducing complexity and the need to memo . longer required.
command names and their parameters. For many use rize
G U~ p resents a more accessible user interface; however,~a
th
• Device management - Keeps track of all the devices.
This is also called 1/0 controller that decides which
ch oice of a user interface is simply a matter of person;
process gets the device, when, and for how much time.
p reference. Examples of GUis are those implemented .
Microsoft ~indows, Apple's Mac OS X, and GNOME/I<D~ • File management - Allocates and de-allocates the
for the X Windows system on Unix-like operating systems. resources and decides who gets the resources.
Objectives of operating system: • Security - Prevents unauthorized access to programs
The objectives of the operating system are : and data by means of passwords and other similar
techniques.
• To make the computer system convenient to use ·
efficient manner. man • Job accounting - Keeps track of time and resources
used by various jobs and/ or users.
• To hide the details of the hardware resources from th
users. e • Control over system performance - Records delays
• To provide users a converu·ent . t £
between the request for a service and from the system.
computer system.. m er ace to use the • Interaction with the operators - Interaction may take
• To act as ru:1 int~rmediary between the hardware and its
place via the console of the computer in the form of
instructions. The Operating System acknowledges the
uthsers, makmg it easier for the users to access and use
o er resources. same, does the corresponding action, and informs the
• To manage the resources of a computer system.
operation by a display screen.
• To keep track of wh0 · • . • Error-detecting aids - Production of dlmlpS; traces,
resource requests andis usmg
d. which
. resource' granting error messages, and other debugging and error-
from different p ' me Iating conflicting requests · detecting methods.
rograms and users.
• To provid e efficient and fa1·r • C d" tion between other software aad 1IIN!IN -
oor ma piJ inte lers
~mong users and programs. sharing of resources Coordination and assignment of com ~ ,pie '
assemblers, and other software to the vanous users of
Characteristics of operating system: the computer systems.
Here is a list of some of the . .
features of operating systems: mo st promment characteristic 6.7 Different Microprocessor Architectures
• Memory man Accumulator-Based Arch 1·tecture .
memory i e arment - Keeps track of the primary based microprocessor architecture,
• ' ·. ., w at part of it is in use by whom what In accumulator: . ·cant register in comparison to other
part is n ot m use etc d , accumulator is the mos~i~thmetic and logical operations are
' · an allocates the memory when a t
process or p r ogram requests it. registers and moS of :,ator. Data can only enter into the ALU
erformed through ac_cu_m_----- -7,;;_;.:~~;;;;;;;~. .~
J /SIGlfTSON MICROPR<>mso.,- - p _ ,_ _ /'"
from accumulator and the out pot of the ALU can be
. stared 1ll
accumulator through data bus. The 8085 microprocessor . CISC machines have large number of. complex instructions
example of accumulator-based architecture. is an • based onmultiple numbers of addressing modes .
Register-Based Architecture CISC machines processer does not consist of large number of
• registers due to large cost. So th~e rnac~es have to
Unlike an accumulator-based microprocessor archit
perform various memory read and wnte operations.
register-based microprocessor architecture has one or mo ecture, a
purpose registers. Data can enter into the ALU from anyre gene . ral • CISC machines are preferable where the speed of processer
Th e 8086 microprocessor is an example of re . registers. is not the prime issue and where general applications are to
architecture. gister-based be handled. Processers like 8085, 8086, 8086,8086,8086,8086
The advantages of register-based architecture is ext d. . . etc are based on CISC processers and even today's pc.
and flexibility in programming. However the d. d en ibiJity
. , 1sa vantage IS. RISC Architecture
requrrement of complex circuitry.
68 The term RISC represents reduced instruction set
· RISC and CISC Architectures computing/ computers. It focuses on a small set of instructions
~c:,s:C:-=A-r ~
c h~ i~te_c....:tu...::...r:.:e=.::...:.::..:::'.~~~'...=~--------- which simplifies the hardware design and improves the processer
performance. Generally, RISC processers include the following
c 1 · features.
ornp ex instruction set computers is the acron
and machine based on this archite tur h ym for CISc
M
ost of the personal com t c. e ave complex instructions.
. • The number of instructions is minimized i.e., less than 100
CISC architecture. Follo1::rs which are used today are based on and each can be executed in a single dodt cycle the data
machines. g are the characteristics of CISC path cycle time is the time required lo &fdi'h operations
from the registers, run them through ALU.,. _._ the
• CISC machines have complex result back to register which is very small hi Jil5C.
large cycles for execution. instructions which need a
• • the number of addressing modes is ~iiliill!i
The transfer of data amon th . than 3 and only few instructions are mas~· _
among memory and
b
ased on memo d
g e register is much faster than
processor In Cisc
·
.
, various instructions
link lode and store so that RISC permits heavy..,,
,ft;
gets reduced.
ry an processer h
so t e processing speed
• Th . .
e processing 1~ regis
• ter intensive, ~
nwst of the ~ - ,-
• Pipelinin · th many more regist':5 an:
performed using registers ange
from 32 ~ I D . . -
g Is e process of fet hin
another instruction • c g one instruction when than 100 registers. . RISC machines tor
. is executing ·
instruction this featu m parallel. Due to complex . coorams m
machines. re cannot be heavily used in CJSC
• There is no oucro-P ti.'.:,., The most instructions ue
. trUC .,._.
interpreting the UU:he hardware.
• Micro-operations f
h . orm the instru ti directly executed b~ include support for high level
e micro-program Wh . h .
Pe £ IC IS Writt
c 0 n and instruction form
. • Design considerations opriate seJection of instruction and
gh appr
r orm timing and en tn control memory to Iansuages thrOU jJerS.
---
imple . sequencing of th . . optimization of cotnP
mented in CISc. e nucro-operatiOl16
-;:;:;:,::------- -
314 INSIGHTS ON MICROPRoce____ _ _
SSORs - - - - _ _ _ _ __,. -----
• . · ~cmd reSearch oriented tasks Where th e
Usuallyf m scien . x issue RJSC machines are Us d
sers 1s ape - ' .e
speedrep
and o 1acmg
proces C w due to reduce the price f
· CIS no - o
hardware.
• RISC based system are R4400SC from MIPS, PA7JO() fro ...
.,.
HP, Power PC fr om APP '
ie IBM and Motorola, uper spare
from sun, iB6QTM from Intel etc.
Differences between RISC and CJSC architecture:
RISC
1. Simple
instructions taking 1.
one c cle.
2. Most operations are register
2. In CISC
to regi$ter with only LOAD machine,
and read & writ operatJons
STORE operations
accessin memor . inherent p rt for e et'Uting
instructions
3. Heavily
pipelined, 3 Not/les pipelined
erformance.
4.
4.
5. Instructions
have fixed 5.
format.
6. format.
Few number of instructions
and addressin modei;. b.
7.
Comp lexity is in the design
of compiler. 7.
8.
Instructions are executed by
hardware. B.
ar
--
An important application of DSPs is in signal coznpre .
and decompression. In CD systems, for example, the music onss10th11
ACI 8-bit data 2 2 7
■
I
CD is in a compressed form so that it doesn't use as much stora e
space. It must be decompressed in order to be reproduced. ~ ADC Reg. 1 1 4
signal compression . is used in cell phones to allow a greater ADCMem. 1 2 7
n umber of calls to be handled simultaneou sly in a local cell.
•
Application areas of DSPs are: ADD Reg. 1 1 4
- II
1. ADDMem. 1 2 7
Telecommunications
2. ADI 8-bit data
Music processing 2 2 7
3. ANA Reg.
Speech generation and recognition 1 1 4
4.
-- -
Radar ANAMem. 1 2 7
5.
■
Image processing ANI 8-bit data 2 2 7
6.
Implementation of digital filters CALL 16-bit 18
address 3 5
(unconditional) - · ··
-I
CMA 4
1 1
CMC 4
1 1
CMPReg. 1 1 4
-
CMPMem. 1 2 7
CPI 8-bit data 2 2 7
DAA
DCRMem. 1 3 10
1 1 6
DCX Reg. pair
1 1 4
DI
318 1 1 4
EI
INSIGHTS ON '-'11CROPROcEssoRs
Af'PENDIX
r1•
Instruction
Bytes Machine Bytes Machine
T-States Instruction T-States
Cycles Cycles
HLT
1 2ormore
~
~
5 or RAR 1 1 4
more ....-
IN 8-bit port address RLC 1 1
2 3 4
INR Reg. 10 >--
1 1 RRC ,1 1 4
INRMem. 4
1 3 RET (unconditional) 1 3
10 10
lNX Reg. pair
1 1 - RlM 1 1
JMP 6 4
16-bit address RST
3 3 1
(unconditional) 10 3 12
SBB Reg. 1
LDA 16-bit address 1 4
3 4 SBBMem.
LDAX B/ D reg. pair 13 1 2 7
1 2 7 SBI 8-bit data
LHLD 16-bit address 2 2 7
3 5
LXI Reg. pair,16-bit data 16 SHLD 16-bit address
3 5 16
3 3
MOV Reg.,Reg. 10 SIM
1 1 1 4
1 4 SPHL
MOV Mem.,Reg. 1
1 1 6
2 7
MOY Reg.,Mem. STA 16-bit address
1 3 4 13
2 7
MVI Reg.,Data STAX B/D reg. pair
2 1 2 7
MVI Mem.,Data
2 7 src
2 1 1 4
NOP 3 10 SUB Reg.
1 1 1 4
ORA Reg. 1 4 SUBMem.
1 1 2 7
ORAMem. 1 4 SUI 8-bit data
1 2 2 7
ORI 8-bit data 2 7 XCHG
2 1 1 4
2 7 XRAReg.
OUT 8-bit port address 1 1 4
2 3
PCHL 10 XRAMem. 1 2 7
1 1
POP Reg. pair 6 XRI 8-bit data 2 2 7
1 3 XTHL
PUSH Reg. pair 10 1 5 16
1 3
RA L 12
1 1 4
320 INSIGHTS ON MICROPROCESSORS
APPENDIX
R,me,h s. G ,onk "· Microprocessor Architecture, Progranznzinc, o, .,,
Applirulion, wdh th, 8085. s• ed. Penran, !nte,-,,•tio"'1J
Publishing (India) Private Limited, 2011.
Wm;.m Slalling,. Ope,aling Sy, tem,. <• ed. hentice 1-laJL 2012.
Willfam SlaJJ;ng,.
Prentice Cnm,,ute, O,ganizalion and A,chUecture. 9• ed.
Han, 2012.
322
•
j i{ence ! and·'Smi{e ,izre two powe,fu[ words. 'Smz[e' is tn f.
sorve many pro 6iems
r. r -
and 'Si{ence' e way tM
is tlie way to avoia mam,p 6' .
, .., ro ie11!s.