Previewpdf
Previewpdf
MICROPROCESSORS
and
MICROCOMPUTER·BASED
SYSTEM DESIGN
MOHAMED RAFIQUZZAMAN, PH.D.
Professor
California State Polytechnic l Tniversity
Pomona, California
and
Adjunct Professor
Univers ity of Southe rn Califo rnia
Los Angeles , California
CRC Press
Boca Raton New York London Tokyo
Library of Congress Cataloging-in-Publication Data
Rafiquzzaman, Mohamed.
Microprocessors and microcomputer-based system design I Mohamed RaJiquzzaman.- 2nd ed.
p. em.
Includes bibliographical references and index.
ISBN 0-8493-4475-1
I. Microprocessors . 2. Intel 80xx series microprocessors. 3. Motorola 68000 series microprocessors.
4. Microcomputers. I. Title.
QA 76 5 R27848 1995
004. 16--dc20 95-7374
CIP
This book contains information obtained from authentic and highly regarded sources. Reprinted material is quoted
with permission. and sources are indicated. A wide variety of references are listed. Reasonable efforts have been made
to publish reliable data and information, but the author and the publisher cannot assume responsibility for the validity
of all materials or for the consequences of their use.
Neither this book nor any part may be reproduced or transmitted in any form or by any means. electronic or
mechanical, including photocopying, microfilming, and recording, or by any information storage or retrieval system.
without prior pem1ission in writing from the publisher.
CRC Press. Inc.'s consent does not extend to copying for general distribution. for promotion. for creating new
works. or for resale. Specific permission must be obtained in writing from CRC Press for such copying.
Direct all inquiries to CRC Press. Inc., 2000 Corporate Blvd .. N.W .. Boca Raton. Florida 33431.
This book is based on the fundamental concepts associated with typical 8-, 16-, and 32-bit
microprocessors and microcomputers. These concepts are related in detail to the Intel 8085/
8086/80386/80486/80960 and Motorola 68000/68020/68030/88100. A brief coverage of Intel
Pentium, Motorola 68040, Motorola/IBM/Apple PowerPC, and DEC's Alpha is also included.
With the growing popularity of both Intel and Motorola 32-bit microprocessors, it is now
necessary to cover these processors at the undergraduate and graduate levels. Therefore, a
thorough coverage of these processors is provided.
A detailed treatment of Intel 80386 and Motorola 68020/68030 along with more examples
and system design concepts is included. Programming and system design concepts associated
with other popular 32-bit microprocessors such as Intel80486/80960 and Motorola 68040 are
also covered in this book. Finally, an overview of Intel Pentium microprocessor is provided.
Since the fundamental concept of 8-bit microprocessors, along with the Intel8085, has proved
its worth many times over in the intervening years, the 8085 has been retained in this edition.
This book is divided into ten chapters. Chapter 1 contains the basics of microprocessors, as
in the first edition. New topics such as floating-point arithmetic, Program Array Logic (PAL)
used for address decoding for 32-bit microprocessors, flash memories and an overview of
various 32-bit microprocessors is also included.
Chapter 2 covers details of the 8085 microprocessor.
Chapters 3 through 8 provide detailed descriptions of the architectures, addressing modes,
instruction sets, 1/0 and system design concepts of Intel's 8086, 80386, 80486, and 80960 and
Motorola's 68000, 68020, 68030, 68040, and 88100 microprocessors. An overview of Intel
80186, 80286, Pentium and PowerPC microprocessors are also included.
Chapter 9 contains fundamentals of peripheral interfacing.
Chapter 10 includes system design concepts along with the applications of design principles
covered in the preceding chapters. Three system design examples using the 8085, 8086, and
68000 are included in detail.
The appendices include materials on the HP 64000 microcomputer development systems,
data sheets on various microprocessors and support chips, and a glossary.
The audience of this book can be college students or practicing microprocessor system
designers in the industry. It can be used as an undergraduate or graduate text in electrical
engineering, computer engineering or computer science. Practitioners of microprocessor
system design in the industry will find greater detail and comparison considerations than are
found in manufacturers' manuals. The book assumes a familiarity with digital logic and topics
such as Boolean Algebra and K-maps.
The author wishes to express his sincere appreciation to his student Frank Lee for making
constructive suggestions and typing the manuscript. The author is also grateful to Dr. W .C.
Miller of University of Windsor, Canada, and others for their support throughout the writing
effort.
Mohamed Rafiquzzaman
Pomona, California
The Author
This chapter provides a brief summary of the features of microprocessors and microcomputer-
based applications.
The basic elements of a computer are the Central Processing Unit (CPU), the Memory, and
Input/Output (I/0) units. The CPU translates instructions, performs arithmetic or logic
operations, and temporarily stores instructions and data in its internal high-speed registers .
The memory stores programs and data. The I/0 unit interfaces the computer with external
devices such as keyboard and display.
With the advent of semiconductor technology, it is possible to integrate the CPU in a single
chip. The result is the microprocessor. Metal Oxide Semiconductor (MOS) technology is
typically used to fabricate the standard off-the-shelf microprocessors such as those manufac-
tured by Intel and Motorola . Appropriate memory and I/0 chips are interfaced to the micro-
processor to design a microcomputer. Single-chip microcomputers are also available in which
the microprocessor, memory, and 1/0 are all fabricated in the same chip. These single-chip
microcomputers offer limited capabilities. However, they are ideal for certain applications
such as peripheral controllers.
Single chip microcomputers are also referred to as "microcontrollers". The microcontrollers
are typically used for dedicated applications such as automotive systems, home appliances and
home entertainment systems. Typical microcontrollers, therefore, include on-chip timers, N
D (Analog to Digital) and D/ A Digital
( to Analog) converters. Two popular microcontrollers
are Intel 8751 (8-bit )/8096 (16-bit) and Motorola HCll (8-bit)/HC16 (16-bit) . The 16-bit
microcontrollers include more on-chip ROM , RAM, and 1/0 compared to the 8-bit
microcontroiJers .
The efficient development of microprocessor-based systems necessitates the use of a micro-
computer development system. The microcomputer development system is used for the
design, debugging, and sometimes the documentation of a microprocessor-based system.
This chapter first covers the evolution of 8-, 16-, and 32-bit microprocessors along with an
overview of programming languages, microcomputer hardware, and software. The attributes
of typical microcomputer development systems features as well as some specific microproces-
sor applications are also included.
2 Microprocessors and Microcomputer-Based System Design, 2nd Edition
therefore, does not use valuable clock cycles (machine cycles) in instruction decoding. Most
RISC instructions require a maximum of only two clock cycles to complete. These instructions
are restricted to register-to-register operations with load and store for memory access. Since
RJSC-type microprocessors are hardwired, instructions may be executed simultaneously (as
long as the instructions do not share the same register.) This technique is known as pipelining.
Pipelining is the mechanism that actually enables simultaneous processing to occur. In-
structions are fetched in sequential order. The processor continues to fetch instructions even
though it has not executed the present instruction. This provides an input pipeline to the
instruction cache. At this stage, the instructions are intelligently fed into the instruction
execution unit for processing. When an instruction is executed, the registers used by the
instruction clear respective bits in a scoreboard register. As the microprocessor is executing a
given instruction, it checks the scoreboard register to see if the next instructions (residing in
a fast read/write memory internal to the microprocessor called the instruction cache) use
registers that are currently in use. Instructions not using the same registers can therefore be
executed at the same time. The RISC microprocessors can execute as many as five instructions
simultaneously.
The trend in microprocessors is implementation of more on-chip functions and for im-
provement of the speeds of memory and 1/0 devices. Some manufacturers are speeding up the
processors for data crunching type applications. Digital Equipment Corporation's Alpha
21164 with 300 MHz clock, four instruction-per-cycle rate and RISC-based architecture is the
fastest microprocessor available today.
Microprocessors store BCD numbers in two forms, packed and unpacked. The unpacked
BCD number represents each BCD digit as a byte while the packed BCD number represents
two BCD digits in a byte. For example, 23 10 is represented as 0000 0010 0000 0011 2 as two
unpacked BCD numbers, while it is represented as 0010 0011 2 as a packed BCD number.
Microprocessors normally input data from a keypad in unpacked BCD form. This data can
then be converted by writing a program in the microprocessor to packed BCD form for
arithmetic operations or for storing in memory. After processing, the packed BCD result is
then converted to unpacked BCD form by another microprocessor program written by the
user for displays. Typical displays use either unpacked BCD data or unpacked BCD data
converted to seven segment code by the microprocessor's program.
1.2.3 ASCII
ASCII (American Standard Code for Information Interchange) is a code that represents
alphanumeric (alpha characters and numbers) in a microcomputer's memory. ASCII also
represents special symbols such as# and o/o. It is a 7 -bit code. The most significant bit (bit 7)
is sometimes used as a parity bit. The parity bit represents the number of ones in the byte. If
the number of ones is odd, the parity is odd; otherwise, the parity is even.
Also, note that the hexadecimal numbers 30 16 through 39 16 are ASCII codes representing the
decimal numbers 0 through 9. A listing of the ASCII codes is included in Appendix F.
I. I 010 = I 0 I 20
2. Normalize the binary number as I.XXXXXX x 2n = 1.010 x 23
3. Sign, S = 0 for positive
4. Biased exponent = 7F 16 + 3 = 82 16
Introduction to Microprocessors and Microcomputer-Based Applications 5
A special case of the floating-point format is called NaN (Not a Number). NaNs are results
generated by floating-point operations that have no mathematical interpretations. These
results may be generated by operations such as multiplication of infinity by infinity.
The BCD floating-point form represents a number in BCD scientific notation . The number
is represented as normalized significand raised to some power of 10. Each BCD floating-point
number is represented in typical microprocessors as 80 bits. The BCD fraction is 16 digits wide
(64-bit) and is stored as packed BCD digits. The whole number portion of the significand is
stored as one digit BCD from 0 to 9. The BCD exponent along with the sign is expressed as
12 bits.
Typical floating-point coprocessors such as 80387 (for the Intel80386 microprocessor) and
6888l/68882 (for the Motorola 68020/68030 microprocessor) support several data types. For
example, the 80387 coprocessor supports seven data types. These are word integer (16-bits),
short integer (32-bit), long integer (64-bit), packed BCD (80-bit), short real (32-bit), long real
(64-bit), and temporary real (80-bit).
The 80387 integer data types are represented by the two's complement same as those used
by the 80386. The only difference is that the 80386 supports an 8-bit integer while the 80387
supports a 64-bit integer.
The 80387 supports 80-bit packed BCD with 18 decimal digits (bits 0-71 ), bit 79 as the sign-
bit and seven (bits 72-78) unused bits. With 18-digits representation, the COBOL standard
(the High level language utilizing BCD) is followed.
The 80387 supports three real data formats. These are short real (32-bit with one sign bit,
8-bit exponent and 23-bit significand) , long real (64-bit with one sign-bit, 11-bit for exponent
and 62-bit for the significand), temporary real (80-bit with one sign-bit, 15-bit exponent, and
64-bit significand).
The 80387 uses the temporary real format internally. All data types are converted by the
80387 immediately into temporary real. This is done to maximum precision and range of
computations.
The 80387 supports four special cases. These are zeros, infinities (both positive and nega-
tive), denormals, and NaNs (signalling and quiet) .
Denormals represent very small numbers that are not normalized. Normally, numbers are
required to be normalized by shifting to left until the most significant is one. Denormals do
not have one as the most significant bit of the significand. Denormals permit a gradual
underflow. That is the precision is lost gradually rather than abruptly. When the least normal-
izable number is reached, the next small representation is zero. Denormals provide gradual
underflow of numbers that are not normalized. That is, denormals extend the range of very
small numbers significantly, but with some loss in precision.
A signaling NaN causes an invalid operation exception when used in an operation. A quiet
NaN, on the other hand, does not cause an invalid operation exception.
The floating-point data types supported by the Motorola 68881/68882 floating-point
coprocessors are summarized next. Note that the 68881 and 68882 differ in execution speed.
They are basically identical. The 68882 is an enhanced version of the 68881 in that it executes
several floating-point instructions concurrentJy with the 68020/68030. The 68881/68882 sup-
ports integers, binary floating-point numbers, and packed floating-point BCD. Data are
represented externally by using these formats. The 68881/68882 utilizes an 80-bit binary
floating point form to represent all data internally.
The 68881/68882 supports three signed integer formats. These are 8-bit byte, 16-bit word,
and 32-bit long word .
6 Microprocessors and Microcomputer-Based System Design, 2nd Edition
Binary floating-point format is also called binary real form. The 68881168882 supports
binary floating-point form which contains three fields. These are a sign , biased exponent and
a significand. The 68881/68882 operates on these sizes, namely 32-bit single-precision, 64-bit
double precision, and 96-bit extended precision.
For single precision (bit 31: sign bit, bits 23-30: 8-bit exponent, bits 0-22: 23-bit significand),
64-bit double precision (bit 63: sign bit, bits 62-52: 11-bit exponent, bits 0-51 : 52-bit significand),
and 96-bit extended-precision (bit 95: sign bit, bits 80-94: IS -bit exponent, bits 64-79: zero;
sixteen unused bits, bits 0-63: 64-bit significand).
The biased exponent is used. The Single Precision adds a bias of 127 10 {7F 16 ), double
Precision uses a bias of 1023 10 (3FF 16 ), and the extended-Precision uses a bias of 16383 10
{3FFFF 16 ). The bias is added to the exponent before it is stored in this format and subtracted
to convert to a true exponent when the number is interpreted.
A few special cases that do not conform to the floating-point form are also handled by the
68881/68882. For example, a zero is represented with all bits of the exponent and significand
as zeros. The sign bit may be a one or a zero representing +0 or -0. The infinity, on the other
hand is represented by all bits in the exponent and significand set to ones. The sign bit may
be zero or one representing positive or negative infinity. The 68881/68882 supports BCD
floating point form which represent each number as normalized significand raised to a power
of 10. This format stores a number as 96 bits. The least significant 64 bits (8 bytes) contain the
16-digit BCD fraction . The next byte contains the whole number portion of the significand {0-
9). The most significant bit (bit 95) contains the sign of significand while bit 94 includes the
sign of the exponent. The exponent is represented by three digit BCD packed exponent {000-
999) in bits 80-91. SimiJar to the 80387, the 68881/68882 also represents NaN's and also
provides exceptions for signaling NaN's.
IEEE has established the standard for floating-point arithmetic specified by ANSI -IEEE754-
1985. Typical 32-bit microprocessors use this standard.
System Bus
I I
Memory
I
Microprocessor 1/0
(ROMIRAM)
On the address bus, information transfer normally takes place only in one direction, from
the microprocessor to the memory or 1/0 elements. Therefore, this is called a unidirectional
bus. This bus is usually 16 to 32 bits wide. The number of unique addresses that the micro-
processor can generate on this bus depends on the width of this bus. For example, for a 16-
bit address bus, the microprocessor can generate 2 16 = 65,536 different possible addresses. A
different memory location or an 1/0 element can be represented by each one of these ad-
dresses.
The data bus is a bidirectional bus, that is, information can flow in both directions, to or
from the microprocessor. This bus is normally 8, 16, or 32 bits wide.
The control bus is used to transmit signals that are used to synchronize the operation of the
individual microcomputer elements. Typical control signals include READ, WRITE, and
RESET. Some signals on the control bus such as interrupt signals are unidirectional, while
some others such as RESET may be bidirectional.
The carry (C) flag is used to reflect whether or not an arithmetic operation such as ADD
generates a carry. The carry is generated out of the 8th bit (bit 7) for byte operations, 16th bit
(bit IS) for 16-bit, or 32nd bit (bit 31) for 32-bit operations. The carry is used as the borrow
flag for subtraction. In multiple word arithmetic operations, any carry from a low-order wo rd
must be reflected in the high-order word for correct results.
The zero (Z) flag is used to indicate whether the result of an arithmetic or logic operation
is zero. Z = l for a zero result and Z = 0 for a non-zero result. The sign flag (sometimes also
called the negative flag) indicates whether a number is positive or negative. S = l indicates a
negative number if the most significant bit of the number is one; S = 0 indicates a positive
number if the most significant bit of the number is ze ro.
The overflow (V) flag is set to one if the result of an arithmetic operation on signed (two's
complement) numbers is too large for the microprocessor's m aximum word size; the C flag
is overflow for unsigned numbers. The overflow flag for signed 8-bit numbers can be shown
as V = C7 EB C6, where C7 is the final carry and C6 is the previous bit's carry. The EB symbol
indicates exclusive-OR operation. This can be illustrated by the numerical examples shown
below:
0000 0100
+ 0000 0010
C7~ o+---0000 OliO
C6=~0--:
From the above, the result is correct when C6 and C7 have the sam e values (0 in this case) .
When C6 and C7 are different, an overtlow occurs. For example, consider the followin g:
C7•1~ resu l! is
incorrect
C6 = 0
The result is incorrect. Since V = C6 E!1 C7 = 0 E!1 I = I, the overflow fl ag is set. Note that this
applies to signed two's complemented numbers only.
The stack pointer (SP) register addresses the stack. A stack is Last- In First-Out (LIFO) read/
write memory in the sense that items that go in last will come o ut first. T his is because stacks
perform all read (POP) and write (PUSH ) o perations from one end.
The stack is addressed by a register called the stack pointer (SP). The size of the SP is
dependent o n the microprocessor's address size. The stack is normally used by subroutines or
interrupts for saving certain registers such as the program counter.
Two instructions, PUSH (stack write) and POP (stack read), ca n usually be perfo rmed by
the programmer to manipulate the stack. If the stack is accessed from the top, the stack pointer
is decremented before a PUSH and incremented after a POP. On the other hand, if the stack
is accessed from the bottom, the SP is incremented before a PUSH and decremented afte r a
POP. Typical microprocessors access the stack from the top. Depending on the microproces-
Introduction to Microprocessors and Microcomputer-Based Applications 9
.---------:.,1rr
:
SP after
SP before
01 5009 01 S009
PUSH
PUSH
5009 .
OS SOOA
I S007 I OS SOOA
F2 SOOB F2 500B
Top oft he
'--------- Stack
I 0721
I I 02 Fl
I
r: F1 50 08 Fl S008
02 50 09 02 S009
v;
SP before POP SP after POP
soOA
I 5008
~
61
I SOOA 61 SOOA
26 soOB 26 SOOB
Top of th e
Stack
sor, an 8-, 16-, or 32-bit register can be pushed onto or popped from the stack. The value by
which the SP is incremented or decremented after POP or PUSH operations depends on the
register size. For example, values of one for an 8-bit register, two for 16-bit registers, and fo ur
for 32-bit registers are used. Figure 1.2 shows the stack data when accessed from the top befo re
and after PUSHing a 16-bit register onto the stack or POPping 16 bits from the stack into the
16-bit register. Note that stack items PUSHed must be POPped in reverse order. The item
pushed last must be popped first.
Consider the PUSH operation in Figure l.2a when the stack is accessed from the top. Th e
SP is decremented by 2 after the PUSH. The SP is decremented since it is accessed from the
top. A decrement value of 2 is used since the register to be pushed is 16 bits wide.
The POP operation shown in Figure 1.2b is the reverse of the PUSH. The SP is incremented
after POP. The contents of locations 5008 16 and 5009 16 are assumed to be empty.
An index register is typically used as a counter for an instruction or for general storage
functions. The index register is useful with instructions where tables or arrays of data are
accessed. The general-purpose register-based microprocessor can use any general-purpose reg-
ister as the index register.
10 Microprocessors and Microcomputer-Based System Design, 2nd Edition
Typical 32-bit microprocessors such as the Intel 80386/80486 and Motorola 68020/68030/
68040 include a special type of shifter called barrel shifter for performing fast shift operations.
The barrel shifter is an on-chip combinational network for 32-bit microprocessors and
provides fast shift operations. For example, the 80386 barrel shifter can shift a number from
0 through 64 positions in one clock period (clock rate is 16.67 MHz).
The ALU in the microprocessor performs all arithmetic and logic operations on data_ The
size of the ALU defines the size of the microprocessor. For example, Intel 8086 (or Motorola
68000) is a 16-bit microprocessor since its ALU is 16 bits wide. The Intel 8088 (or Motorola
68008) is also a 16-bit microprocessor since its ALU is 16 bits wide, even though its data bus
is 8 bits wide. Motorola 68040 (or Intel 80486) is a 32-bit microprocessor since its ALU is 32
bits wide. The ALU usually performs operations such as binary addition and subtraction. The
32-bit microprocessors include multiple ALUs for parallel operations and thus achieve fast
speed.
The control unit of the microprocessor performs instruction interpreting and sequencing.
In the fetch phase, the control unit reads instructions from memory using the PC as a pointer.
It then recognizes the instruction type, gets the necessary operands, and routes them to the
appropriate functional units of the execution unit. Necessary signals are issued to the execu-
tion unit to perform the desired operations, and the results are routed to the specified
destination.
In the sequencing phase, the control unit determines the address of the next instruction to
be executed and loads it into the PC. The control unit is typical.ly designed using one of three
techniques:
Hardwired control
Microprogramming
• Nanoprogramming
The hardwired control unit is designed by physically connecting typical components such
as gates and flip-flops. Typical 32-bit RISC microprocessors such as the Intel 80960 and
Motorola 88100 are designed using hardwired control. The microprogrammed control unit
includes a control ROM for translating the instructions. Intel 8086 is a microprogrammed
microprocessor. Nanoprogramming includes two ROMs inside the control unit. The first
ROM (microROM) stores all the addresses of the second ROM (nanoROM). If the microin-
structions (which is the case with the 68000/68020/68030/68040) repeat many times in a
microprogram, use of two-level ROMs provides tremendous memory savings. This is the
reason that the control units of the 68000, 68020, 68030, and 68040 are nanoprogrammed.
However, the cost involved in this approach forces a microcomputer architect to include only
a few registers (usually 8 or 16) in the microprocessor.
Primary or main memory is the storage area in which all programs are executed. The
microprocessor can directly access only those items that are stored in primary memory.
Therefore, all programs and data must be within the primary memory prior to execution.
Secondary memory refers to the storage medium comprising slow devices such as magnetic
tapes and disks. These devices are used to hold large data files and huge programs such as
compilers and data base management systems which are not needed by the processor fre-
quently. Sometimes secondary memories are also referred to as auxiliary or backup store or
virtual memory.
Secondary memory stores programs and data in excess of the main memory. The micro-
computer cannot directly execute programs stored in the secondary memory. In order to
execute these programs, the microcomputer must transfer them to its main memory by a
system program called the operating system. This topic is covered later in the chapter.
Data in disk memories are stored in tracks. A track is a concentric ring of data stored on a
surface of a disk. Each track is further subdivided into several sectors. Each sector typically
stores 512 or 1024 bytes of data. AJI disk memories use magnetic media except the optical disk
memory which stores data on a plastic disk. Data is read or sometimes written on the optical
disk with a laser beam. There are two types of optical disks. These are the CD-ROM (Compact
Disk Read Only Memory) and the WORM (Write Once Read Many) . The CD-ROM is
inexpensive compared to the WORM drive. However it suffers from lack of speed and has
limited software applications at the present time. The WORM drive is typically used in huge
data storing applications such as insurance and banking since data can be written only once.
The optical disk memory is currently becoming popular with microcomputer systems. One of
the commonly used disk memories with microcomputer systems is the floppy or flexible disk.
The floppy disk is a flat, round piece of plastic coated with magnetically sensitive oxide
material . The disk is provided with a protective jacket to prevent fingerprints or foreign matter
from contaminating the disk's surface. The floppy disk is available in three sizes. These are the
8 inch, 5.25 inch, and 3.5 inch. The 8 inch floppy disk is not used in present systems. These
days, the 5.25 inch and 3.5 inch are very popular. Also, the 3.5 inch floppy is replacing the 5.25
inch floppy in newer systems since it is smaller in size and does not bend easily. AU floppy disks
are provided with an off-center index hole that allows the electronic system reading the disk
to find the start of a track and the first sector.
Hard disk memory is also frequently used with microcomputer systems. The hard disk, also
known as the fixed disk, is not removable like the floppy disk.
A comparison of the some of the features associated with the hard disk and floppy disk is
provided below:
Size 5 Mbytes to several Gbytes 1.2 Mbytes typical to r 5.25 inch tloppy.
1.44 Mbyte typical for 3.5 inch tloppy.
Rotational Speed 3600 rpm 300 rpm
Number of heads May have up to 8 disk surfaces with up to Two heads; One head for the upper surface
two heads per surface and the other head fo r the lower surface
Primary memory normaJiy includes ROM (Read-only Memory) and RAM (Random Access
Memory). As the name implies, a ROM permits only a read access. Some ROMs are custom
made, that is, their contents are programmed by the manufacturer. Such ROMs are called
mask programmable ROMs. Sometimes a user may have to program a ROM in the field. For
instance, in a fusible-link ROM, programmable read-only memory (PROM) is available. The
main disadvantage of a PROM is that it cannot be reprogrammed.
12 Microprocessors and Microcomputer-Based System Design, 2nd Edition
Some ROMs can be reprogrammed, these are called Erasable Programmable Read-Only
Memories (EPROMs).
In an EPROM, programs are entered using electrical impulses and the stored information
is erased by using ultraviolet rays. Usually an EPROM is programmed by inserting the EPROM
chip into the socket of a PROM programmer and providing program addresses and voltage
pulses at the appropriate pins of the chip. Typical erase times vary between I 0 and 30 minutes.
With advances in IC technology, it is possible to achieve an electrical means of erasure.
These new ROMs are called Electrically Alterable ROMs (EAROMs) or Electrically Erasable
PROMs (EEPROMs or £2PROMs) and these ROM chips can be programmed even when they
are in the circuit board. These memories are aJso caJled Read Mostly Memories (RMMs), since
they have much slower write times than read times. Random Access Memories (RAMs) are
read/write memories.
Information stored in random access memories will be lost if the power is turned off. This
property is known as volatility and, hence, RAMs are usually called volatile memories. RAMs
can be backed up by batteries for a certain period of time and are sometimes called nonvolatile
RAMs. Stored information in a magnetic tape or magnetic disk is not lost when the power is
turned off. Therefore, these storage devices are called nonvolatile memories. Note that a ROM
is a nonvolatile memory.
Some RAMs are constructed using bipolar transistors, and the information is stored in the
form of voltage levels in flip-flops. These voltage levels do not usually drift away, or decay. Such
memories are called static RAMs because the stored information remains constant for some
period of time.
On the other hand, in RAMs that are designed using MOS transistors, the information is
held in the form of electrical charges in capacitors. Here, the stored charge has the tendency
to decay. Therefore, a stored 1 would become a 0 if no precautions were taken. These memories
are referred to as dynamic RAMs. In order to prevent any information loss, dynamic RAMs
have to be refreshed at regular intervals. Refreshing means boosting the signal level and writing
it back. This activity is performed by a hardware unit called "refresh logic" which can either
be a separate chip or is contained in the microprocessor chip.
Since the static RAM maintains information in active circuits, power is required even when
the chip is inactive or in standby mode. Therefore, static RAMs require large power supplies.
Also, each static RAM cell is about four times larger in area than an equivalent dynamic cell;
a dynamic RAM chip contains about four times as many bits as a static RAM chip using the
same or comparable semiconductor technology. Figure 1.3 shows the subcategories of ROMs,
RAMs, and their associated technologies.
PRIMARY MEMORY
RAM ROM
Magneti c Semiconductor I
Bipolar MOS
II
Core
Today, one megabit of data can be stored in an ordinary dynamic RAM chip. The data can
be accessed in 80 nanoseconds or less. The RAM chip costs $5. In contrast, it takes 150
nanoseconds to access a one-megabit EEPROM which costs $150. Sixteen megabit DRAMs are
very popular Lhese days at a price of approximately 0.3 millicent per bit. Recently, IBM,
Hitachi, Toshiba and others have introduced 64 mega-bit DRAMs. It is expected that giga-bit
DRAMs will not be introduced until the next century.
In the mid 1980s, Toshiba Semiconductor invented flash memory. About the same time,
Intel and Seeq Semiconductor were also working on flash memories. While each manufacturer
implemented its flash memory differently, they operate in a similar way.
Like EPROMs and EEPROMs or EAR OMs, flash memory is nonvolatile and reprogrammable.
Flash memory is fabricated by using ETOX II (EPROM Tunnel Oxide) technology which is a
combination of EPROM and EEPROM technologies. Flash memory is relatively inexpensive
compared to EEPROM. A one megabit flash memory costs about $15. Flash memory can be
reprogrammed electrically while embedded in the board. However, one can only change a
sector or a block (consisting of multiple bytes) at a time.
Flash memory cells contain a single transistor like the EPROM cell. In contrast, a DRAM cell
typically contains a transistor and a capacitor, an EEPROM cell contains two transistors while
a static RAM cell requires four or six transistors.
The non-volatility and DRAM-like speed of flash memory are ideal for solid-state "disk"
drives. Flash based disks do not have any disks or moving parts. Flash disks are very fast
compared to most available disk drives.
Data can be accessed in 120 nanoseconds in flash memories while it takes 15 to 30 millisec-
onds to access data stored in today's typical hard disk. However, flash disks are limited to up
to 40 megabytes in capacity whereas hard disk drives can store from 5 megabytes to several
gigabytes.
A flash disk can be built from one or more flash-memory IC chips and some controlling
logic devices. For example, to build a 512Kbyte flash disk, four one-megabit flash memory
chips can be connected on a smaU card. An example of such a flash memory system is the Intel
iMC004FLKA 4 Megabyte flash memory card. In addition to flash-disk hardware, software to
manage fLies on a flash disk is required. The file system software handles creating and deleting
files, changing the file sizes and formatting the flash disk. Microsoft offers flash file system
software for the MS-DOS operating system.
The most severe limitation of flash disks has been its cost. However, the cost of flash ROM
is significantly decreasing. In the future, high density flash memory is expected to be available
at an inexpensive cost.
Flash memory can be programmed using either 5V or 12V. The 5V feature becomes more
desirable for portable equipment where no 12V power is available. The speed, rugged con-
struction, and lower power consumption of flash disks is ideal for laptop and notebook
computers.
In summary, due to the high cost of flash disks, desktop computers will continue to use hard
disk drives. Since flash memory combines the advantages of an EPROM's low cost with an
EEPROM's ease of reprogramming, flash memories are being extensively used these days as a
microcomputer's main non-volatile memory. An example of flash memory is the Intel28F020
256K x 8 flash memory. By 1997, the cost of a megabyte of flash memory is expected to move
from its current level of $120 to about $5. At that time, flash disks will be able to replace hard
disks in many applications .
There are three types of techniques used for designing the main memory. These are linear
decoding, full decoding/partial decoding and memory decoding using PALs. We will illustrate
the concepts associated with these techniques in the following.
First, consider the block diagram of a typicaJ static RAM chip shown in Figure 1.4.
A9- AO flO
I
- 1Kx8
WE
RAM chip 8/ .,.,. .... 07- DO
I .......
,....
cs
The capacity of this chip is 8192 bits and these bits are organized as I 024 words with 8 bits/
word. Each word has a unique address and this is specified on !O-bit address lines A9-AO
(note that 2 10 = 1024). The inputs and outputs are routed through the 8-bit bidirectional data
lines D7 through DO. The operation of this chip is governed by the two control inputs: WE
(write Enable) and CS (chip select). The truth table that describes the operation of this chip
is shown in Table 1.1.
From this table, it is easy to see that when CS input is low, the chip is not selected and thus
the lines D7 through DO are driven to the high impedance state. When CS = I and WE is LOW,
data on lines D7-DO are written into the word addressed by AO through A9. Similarly, when
CS = 1 and WE is high, the contents of the memory word (whose address is specified on
address lines A9 through AO) will appear on lines D7 through DO. Note that when the chip
select input CS goes to low, the device is disabled and the chip automatically reduces its power
requirements and remains in this low-power standby mode as long as CS remains low. This
feature results in system power savings as high as 85% in larger systems, where the majority
of devices are disabled.
l.J.J.b.i Linear Decoding. This technique uses the unused address Jines of the microprocessor as chip
selects for the memory chips. This method is used for small systems.
A simple way to connect an 8-bit microprocessor to a 6K RAM system using linear
decoding is shown in Figure 1.5. In this approac h, the address lines A9 through AO of the
microprocessor are used as a common input to each I K x 8 RAM ch ip. The remaining 6
high - order lin es are u sed to selec t one of the 6 RAM chips. For examp le, if
Al5Al4Al3AI2A11AIO = 000010, then the RAM chip l is selected. The address map
realized by this arrangement is summarized in Figure J .6. This method is known as the linear
select decoding technique. The principal adva ntage of this method is that it does not require
any decoding hardware. However, this approac h has some disadvantages:
Introduction to Microprocessors and Microcomputer-Based Applications 15
• Although with a 16-bit address bus we have 64K bytes of RAM space, we are able to
interface only 6K bytes of RAM. This means that this idea wastes address space.
The address map is not contiguous; rather, it is sparsely distributed.
Ifboth All and AlO are high at the same time, both RAM chips 0 and 1 are selected and
thus a bus conflict occurs. This can be avoided by proper programming to select the
desired memory chip and deselect the others.
Also, if all unused address lines are not utilized as chip selects for memory, then these
unused pins become don't cares (can be 0 or 1). This results in foldback, meaning that
a memory location will have its image in the memory map. For example, if A15 is don't
care in design and if A14 to AO address lines are used, then address 0000 16 and address
8000 16 are the same locations. This is called foldback and it wastes memory space .
. 3.3.b.ii Full/Partial Decoding. Difficulties such as the bus conflict and sparse address distribution
are eliminated by the use of the full/partial decoded addressing technique. To see this, consider
the organization shown in Figure 1.7. In this setup, we use a 2-to-4 decoder and interface the
8-bit microprocessor with 4K bytes of RAM. In particular, the four combinations of the lines
All and AlO select the RAM chips as follows:
All AIO Device Selected
0 0 RAM chip 0
0 I RAM chip I
0 RAM chip 2
RAM chip 3
Also observe that this hardware makes sure that the memory system is enabled only when
the lines AlS through Al2 are zero. The complete address map corresponding to this organi-
zation is summarized in Figure 1.8 .
8- BIT MICROPROCESSO R B US
+----+-----1 A9-AO
07 - 00~~8~--4
+---I WE
~--~-+--~CS
'-----------'
RAM CHIP 1
(1 K X 8 )
+----+-----1 A9-AO
D7 -Do~~8;;<---4
+----I WE
~----+--,~-_, cs
'------------'
RAM C H IP 2
( 1 K X 8)
+----+----1 A9-AO
0 7 - 00~~8;<---4
+----I WE
'---------~-+--~CS
'------------'
RAM C HIP 3
(1 K x 8)
+----+-------1 A9-AO
D7-D0~~8,_--4
+----I WE
cs
RAM C HIP 4
(1 K x 8)
+----+-------1 A 9 -AO
D7-D0~~8~--~
+----!WE
' - - - - - - - - - - - - + - - + - - - - - - - 1 CLS
__ _ _ __ J
RAM C HIP 5
(1 K X 8)
~wE
'------------------~cs
L _ __ _ _ _ _ J
FIGURE 1.5 An 8-bit microprocessor interfaced to a 6K RA.Ivl system using the linear select decoding technique.
Some PALs provide additional features. The l6L8 includes tristate outputs. Each of the eight
NOR gate outputs is driven internally by six AND gates. A seventh AND gate provides the
enable signal for the tristate buffers.
The 1618 is a popular PAL used with 32-bit microprocessors. The 16L8 is a 20-pin PAL
manufactured using bipolar transistors. It has ten input pins (labeled 1), hvo outputs (labeled
0) and six programmable Input/Output (labeled 110) Jines. Using the programmable I/0
lines, the number of input lines can be increased to a maximum of 16 and the number of
output lines can be increased to 8.
Introduction to Microprocessors and Microcomputer-Based Applications 17
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 RAM 0400
CHIP to
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 07FF
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 RAM 0800
CHIP to
0 0 0 0 1 0 1 1 1 1 1 1 1 1 1 1 OBFF
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 RAM 1000
CHIP to
0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 2 13FF
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 RAM 2000
CHIP to
0 0 1 0 0 0 1 1 1 1 1 1 1 1 1 3 23FF
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 RAM 4000
CHIP to
0 1 0 0 0 0 1 1 1 1 1 1 1 1 1 4 43FF
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 RAM 8000
CHIP to
1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 5 83FF
FIGURE 1.6 Address map realized by the system shown in Figure 1.5.
Programming PALs can be accomplished by first creating a file by using a text editor o n a
personal computer. The file should include information such as the pin assignments of the
PAL and the boolean equation for the outputs. By inserting the PAL into the programming
module included with the personal computer, the PAL can then be programmed with the PAL
programming software provided with the personal computer.Note that PAL programmi ng
hardware and software are sold separately and not usually included with a personal compute r.
+--+---iA9-AO
D7 -DOt--...;&;o,.__-;
INV -WE
~~04~6--r_,__-Lc_s___~
RAM CHIP 0
(1Kx8)
~-~-~A9-AO
D7-DOJ---i'-'----~
8
INV '------WE
74LS04
~~,-~8_ _ _ _~LCS_____~
FIGURE 1.7 An 8-bit microprocessor interfaced to a 4K RAM system using a fuiUpartial decoded addressing
technique
Device
Binary Address Pallern Selected Address Assignm e nt in Hex
A 1S A 14 A 13 A 12 A 11 A 10 A9 A7 A6 AS A4 AJ A2 A 1 AO
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 RAM 0000
CH IP 10
0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 03FF
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 RAM 0400
CHIP to
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 07FF
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 RAM 0800
CHIP to
0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 2 OBFF
0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 RAM ocoo
CHIP to
0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 3 OFFF
FIGURE 1.8 Address map corresponding to the organization shown in Figure 1.7.
Introduction to Microprocessors and Microcomputer-Based Applications 19
lo-----1
~---r---+--~--~r---+----r-
12-----1
~---r---+--~--~r---+----r-
program are called logical addresses since they indicate the logical positions of instructions and
data. The MMU translates these logical addresses to physical addresses provided by the
memory chips. The MMU can perform address translation in one of two ways:
l. By using the substitution technique as shown in Figure l.lOa
2. By adding an offset to each logical address to obtain the corresponding physical address
as shown in Figure l.lOb
Address translation using substitution is faster than the offset method . However, the offset
method has the advantage of mapping a logical address to any physical address as determined
by the offset value.
Memory is usually divided into small manageable units. The terms "page" and "segment"
are frequently used to describe these units. Paging divides the memory into equal-sized pages,
while segmentation divides the memory into variable-sized segments.
It is relatively easier to implement the address translation table if the logical and main
memory spaces are divided into pages. The term "page" is associated with logical address
space, while the term "block" usually refers to a page in main memory space.
There are three ways to map logical addresses to physical addresses. These are paging,
segmentation, and combined paging/segmentation.
In a paged system, a user has access to a larger address space than physical memory provides.
The virtual memory system is managed by both hardware and software. Note that memory in
excess of the main memory such as floppy disk storage is called virtual memory. The hardware
included in the memory management unit handles address translation. The memory manage-
ment software in the operating system performs all functions including page replacement
policies in order to provide efficient memory utilization. The memory management software
performs functions such as removal of the desired page from main memory to accommodate
a new page, transferring a new page from secondary to main memory at the right instant of
time, and placing the page at the right location in memory.
20 Microprocessors and Microcomputer-Based System Design, 2nd Editior
Logical Logical
Address Address
Physical Physical
Address Adcir(·S~
Physical
" Address
OFFSET
If the main memory is full during transfer from secondary to main memory, it is necessaf)
to remove a page from main memory to accommodate the new page. Two popular pagt
replacement policies are first -in first-out (FIFO) and least recently used (LRU) . T he FIFC
policy removes the page from main memory that has been resident in memory for the longesl
amount of time. The FIFO replacement policy is easy to implement. One of the main disad-
vantages of the FIFO policy is that it is likely to replace heavily used pages. Note that heavily
used pages are resident in main memory for the longest amount of time. Sometimes this
replacement policy might be a poor choice. For example, in a time-shared system, several users
normally share a copy of the text editor in order to type and correct programs. The FIFO policy
on such a system might replace a heavily used editor program page to make room for a new
page. This program page might be recalled to main memory immed iately. T he FIFO, in this
case, would be a poor choice.
The LRU policy, on the o ther hand, replaces that page which has not been used for the
longest amou nt of time.
In the segmentation method, the MMU utilizes the segment selector to obta in a descriptor
from a table in memory containing several descriptors. A descriptor contains the physical base
address for a segment, the segment's privilege level, and some control bits. When the MMU
obtains a logica l add ress from the microprocessor, it first determ ines whether the segment is
already in the physical memory. If it is, the MMU adds an offset component to the segment
base component of the address obtained from the segment descriptor table to provide the
physical address. The MMU then generates the physical address on the add ress bus for
accessing the memory. On the other hand, if the MMU does not find the logica l add ress in
physical memory, it interrupts the microprocessor. The microprocessor executes a service
routine to bring the desired program from a secondary memory such as disk to the physical
memory. T he MMU determines the physical address using the segment offset and descriptor
as above and then generates the physical address on the address bus fo r memory. A segment
will usually consist of an integral number of pages, say, each 256 bytes long. With diffe rent-
sized segments being swapped in and out, areas of valuable primary memory can become
unusable. Memory is unusable for segmentation when it is sandwiched between already
a llocated segments and if it is not large enough to hold the latest segment that needs to be
Introduction to Microprocessors and Microcomputer-Based Applications 21
loaded. This is called external fragmentation and is handled by MMUs using special tech-
niques. An example of external fragmentation is given in Figure 1.11. The advantages of
segmented memory management are that few descriptors are required for large programs or
data spaces, and internal fragmentation (to be discussed later) is minimized. The disadvan -
tages include external fragmentation, involved algorithms for placing data are required, pos-
sible restrictions on starting address, and longer data swap times are required to support
virtual memory.
ALLOCATED ~
Address translation using descriptor tables offers a protection feature. A segment or a page
can be protected from access by a program section of a lower privilege level. For example, the
selector component of each logical address includes one or two bits indicating the privilege
level of the program requesting access to a segment. Each segment descriptor also includes one
or two bits providing the privilege level of that segment. When an executing program tries to
access a segment, the MMU can compare the selector privilege level with the descripto r
privilege level. If the segment selector has the same or higher privilege level, then the MM U
permits the access. If the privilege level of the selector is lower than the descriptor, the MM U
can interrupt the microprocessor informing of a privilege level violation. T herefore, the
indirect technique of generating physical address provides a mechanism of protecting critical
program sections in the operating system .
Paging divides the memory into equal-sized pages, it avoids the major problem of segmen-
tation-external fragmentation . Since the pages are of the same size, when a new page is
requested and an old one swapped out, the new one wiiJ always fit into the vaca ted space.
However, a problem common to both techniques remains- internal fragmentation . Interna l
fragmentation is a condition where memory is unused but allocated due to memory block size
implementation restrictions. This occurs when a module needs, say, 300 bytes and page is I K
bytes, as shown in Figure 1.12.
In the paged-segmentation method , each segment contains a num ber of pages. The logical
address is divided i.nto three components: segment, page, and word. The segment com ponent
defines a segment number, the page component defines the page within the segment, and the word
component provides the particular word \vi thin the page. A page co mponent of n bits can provide
up to 2" pages. A segment can be assigned with one or more pages up to a maximum of 2" pages;
therefore, a segment size depends on the number of pages assigned to it.
Protection mechanisms can operate either on physical address or logical address. Physical
memory protection can be accomplished by using one or more protection bits with each block
to define the access type permitted on the block. This means that each time a page is transferred
from one block to another, the block protection bits must be updated. A more efficient
approach is to provide a protection feature in logical address space by including protection bits
in the descriptors of the segment table in the MMU.
22 Microprocessors and Microcomputer-Based System Design, 2nd Edition
PAGES=1 K
IF 300 BYTES NEEDED 1 K BYTES ARE ALLOCATED
-~
USED
1
BUT
ALLOCATED
-'----
FIGURE Ll2 Memory fragmentation (internal).
-----1
Microprocessor
I
I_------
-
On-chip
Internal to the cache
mi< roprocessor memory
chip
I
--F-------J
,----L---'--;
Main Memory
FIGURE 1.13 Memory Or[\anization of a computer sy,tern that employ' a cache memory.
bit address accesses the code. Ea€h word in the cache includes the data word and its associated
tag. When the microprocessor generates an address for main memory, the index field is used
as the address to access the cache. The tag field of the main memory is compared with the tag
field in the word read from cache. A hit occurs if the tags match. This means that the desired
data word is in cache. A miss occurs if there is no match, and then the required word is read
from main memory. It is written in the cache along with the new tag. A random access memory
is used as the cache memory.
One of the main drawbacks of direct mapping is that numerous misses may occur if two or
more words with addresses having the same index but ditferent tags are accessed several times.
This can be minimized by incorporating a larger cache.
The fastest cache memory utilizes an associative memory. The method is known as fully
associative mapping. Each associative memory content contains main memory address and its
content (data). \Vhen the microprocessor generates a main memory addre~'>, it is compared
associatively (simultaneously) with all addresses in the associative memory. If there is a match,
the corresponding data word is read from the associative cache memory and sent to the
microprocessor. If a miss occurs, the main memory is accessed, and the address and its
corresponding data are written to the associative cache memory. If the cache is fuiJ, certain
policies such as FIFO (first-in first-out) are used as replacement algorithm for the cache. The
associative cache is expensive but provides fast operation.
The set-associative mapping is a combination of direct and associative mapping. Each cache
word stores two or more main memory words using the same index address. Each main
memory word consists of a tag and its data word. An index with two or more tags and data
words forms a set. When the microprocessor generates a memory request, the index of the
main memory address is used as the cache address. The tag field of the main memory address
is then compared associatively (si multaneously) with all tags stored under the index. If a match
occurs, the desired data word is read. If a miss occurs, the data word, along with its tag, is read
from main memory and also written into the cache. The hit ratio improves as the set size
increases. This is because more words with the same index but different tags can be stored in
cache.
There are two ways of writing into cache: the write-back and write-through methods. In the
write-back method, whenever the microprocessor writes something into a cache word, a dirty
bit is assigned to the cache word. When a dirty word is to be replaced with a new word, the
24 Microprocessors and Microcomputer-Based System Design , 2nd Edition
dirty word is first copied into the main memory before it is overwritten by the incoming new
word . The advantage of this method is that it avoids unnecessary writing into main memory.
In the write-through method, whenever the microprocessor alters cache data, the same
alteration is made in the main memory copy of the altered cache data. This policy can be easily
implemented and also it insures that the contents of the main memory are always valid. This
feature is desirable in a multiprocessor system where the main memory is shared by several
processors. However, this approach may lead to several unnecessary writes to main memory.
One of the important aspects of cache memory organization is to devise a method that
insures proper utilization of the cache. UsuaUy, the tag directory contains an extra bit for each
entry. This additional bit is called a valid bit. When the power is turned on, the valid bit
corresponding to each cache block entry of the tag directory is reset to zero. This is done in
order to indicate that the cache block holds invalid data. When a block of data is first
transferred from the main memory to a cache block, the valid bit corresponding to this cache
block is set to l. In this arrangement, whenever the valid is a zero, it implies that a new
incoming block can overwrite the existing cache block. Thus, there is no need to copy the
contents of the cache block being replaced into the main memory.
Programmed 1/0
Interrupt d riven I/0
Direct memory access (DMA)
For a microcomputer with an operating system, the user works with virtual 1/0 devices. The
user does not have to be familiar with the characteristics of the physical 1/0 devices. Instead,
the user performs data transfers between the microcomputer and the physical 1/0 devices
indirectly by calling the J/0 routines provided by the operating system using virtual 1/0
instructions. This is called logical I/0 .
7 6 5 4 3 2 0 Bir posirion
1/ 0 porr
i i 1 1 i 1 i T
In the preceding example, since 34 16 (00 11 0 1002 ) is sent as an output into the data-direction
register, bits 0, I, 3, 6, and 7 of the port are set up as inputs, and bits 2, 4, and 5 of the port
are defined as outputs. The microcomputer can then send outputs to external devices, such as
LEOs, connected to bits 2, 4, and 5 through a proper interface. Similarly, the microcomputer
can input the status of external devices, such as switches, through bits 0, I, 3, 6, and 7. To input
data from the input switches, the 8-bit microcomputer assumed here inputs the complete byte,
including the bits to which LEOs are co nnected. While receiving input data from .m 1/0 port,
however, the microcomputer places a value, probably 0, at the bits configured as outputs and
the program must interpret them as "don't cares" . At the same time, the microcomputer's
outputs to bits configured as inputs are disregarded .
For parallel I/O, there is only one register, known as the command register, for all ports. A
particular bit in the command register configures all bits in a port as either inputs or outputs.
Consider two 1/0 ports in an 1/0 chip along with one command register. Ass ume that a 0
or a 1 in a particular bit position defines all bits of ports A or B as inputs or outputs.
26 Microprocessors and Microcomputer-Based System Design, 2nd Edition
For example,
7 2 1 0
E- - - - -I IP~rt
7 0 7 0
I E- - - - - - -1 IP~rt
f --- -----=-t }- -- - --- -~
Input Devices Output Devices
Some I/0 ports are caJJed handshake ports. Data transfer occurs via these ports through
exchanging of control signals between the 1/0 controller and an external device.
I/0 port mapped as a memory address. Motorola, on the other hand, does not have any IN or
OUT instructions and uses memory-oriented instructions for I/0 operation .
Vx
START
conversion t 07
, 06
05
8-bit
BUSY 8-bit 04 tri-state
(end of conversion )
... Tri-state
ND converter 03
digital
output
"' 02
ou TPUT ENABLE Dl
DO
The AID converter just shown transforms an analog voltage Vx into an 8-bit binary output
at pins 07-00. A pulse at the START conversion pin initiates the conversion. This drives the
BUSY signal LOW. The signal stays LOW during the conversion process. The BUSY signal goes
HIGH as soon as the conversion ends. Since the ND converter's output is tristated, a LOW
o n the (OUTPUTENABLE) transfers the converter's output. A HIGH on the
(OUTPUT ENABLE) drives the converter's output to a high impedance state.
The concept of conditional I/O can be demonstrated by interfacing the ND converter to an
8-bit processor. Figure 1.14 shows such an interfacing example.
The user writes a program to carry out the conversion process. When this program is
executed, the processor sends a pulse to the START pin of the converter via bit 2 of port A. The
microprocessor then checks the BUSY signal by bit 1 of port A to determine if the conversion
is completed . If the BUSY signal is HIGH (i ndicating the end of conversion), the micropro-
cessor sends a LOW to the (OUTPUT ENABLE) pin of the AID converter. The microproces-
sor then inputs the converter's 00-07 outputs via port B. If the conversion is not completed ,
the microprocessor waits in a loop checking for the BUSY signal to go HIGH .
Vx
~
Bit 0 OUTPUT ENABLE
Port A Bit 1 BU SY
..
Bit 2 START
.. ...
Bit 7 07
Port B
Bit 0 DO
Processor ND Con verter
+5 v
Q, I~ ~
r
Microprocesso r output
Q, 1
~
FIGURE 1.15 Digital microprocessor output circuit.
In the preceding figure, when Q1 is ON , Q 2 is OFF and I,;nk will flow from the external device
into Q 1• Also, when Q 2 is ON, Q 1 is OFF and ! so urce will flow from Q 2 into the output device.
Figure 1.16 shows a hardware interface circuit using the push-pull circuit for driving an
external device such as LED.
Assume ! so urce to be 400 ~A (usually represented by a negative sign such as ! 0 H = -400 ~;
the negative sign indicates that the chip is losing current) with a minimum voltage VAof 2.4
at point A, and that the LED requires lOrnA at 1. 7 V. Therefore, a buffer such as a transistor
is required at the output circuit to increase the current drive capabiJity to drive the LED. In
order to design the interface, the values of R1,R 2 and minimum ~ of the tra nsistor will be
determined in the following:
-5 v
r--------------,
+5 v ~R 2
--.-----02--,1 ~ \ ' ~"'co ~LED
VA~
I
:~Buffer
_ _ _ _ _ _ _ _ __.l I
- _J
Therefore, the interface design is complete, and a transistor with a mimimum of saturation ~
of25 and R1 = 4.25 kQ and R2 = 330 Q is required. Note that aMOS outputs more sink current
than source current. If sink current is used, the LED in Figure 1.16 can directly be connected
to the microcomputer's output through an appropriate resistance. However, if the resistor
value is not large enough, it may damage the transistor Ql.
1.3.4.e.i Interrupt Types. There are typically three types of interrupts: external interrupts, traps or
internal interrupts, and software interrupts.
External interrupts are initiated through the microcomputer's interrupt pins by external
devices such as AID converters. External interrupts can further be divided into two types:
maskable and nonmaskable. A maskable interrupt is enabled or disabled by executing instruc-
tions such as EI or DI. If the microcomputer's interrupt is disabled, the microcomputer
ignores the maskable interrupt. Some microprocessors, such as the Intel 8086, have an inter-
rupt-flag bit in the processor status register. When the interrupt is disabled, the interrupt-flag
bit is I, so no maskable interrupts are recognized by the processor. The interrupt-flag bit resets
to zero when the interrupt is enabled.
The nonmaskable interrupt has higher priority than the maskable interrupt. Ifboth maskable
and nonmaskable interrupts are activated at the same time, the processor will service the
nonmaskable interrupt first. The nonmaskable interrupt is typically used as a power failure
interrupt. Microprocessors normally use +5 V DC, which is transformed from llO V AC. If
the power falls below 90 V AC, the DC voltage of +5 V cannot be maintained. However, it will
take a few milliseconds before the AC power can drop this low (below 90 V AC). In these few
milliseconds, the power failure-sensing circuitry can interrupt the microprocessor. An inter-
rupt service routine can be vrritten to store critical data in nonvolatile memory such as battery-
backed CMOS RAM. The interrupted program can continue without any loss of data when the
power returns.
Some microprocessors are provided with a maskable handshake interrupt. This interrupt is
usually implemented by using two pins- INTR and INTA. When the INTR pin is activated
by an external device, the processor completes the current instruction, saves at least the current
program counter onto stack, and generates an interrupt acknowledge ( INTA) . In response to
the !NTA, the external device provides an instruction, such as CALL, using external hardware
on the data bus of the microcomputer. This instruction is then read and executed by the
microcomputer to branch to the desired service routine.
Internal interrupts, or traps, are activated internally by exceptional conditions such as
overflow, division by zero, or execution of an illegal op-code. Traps are handled the same way
as external interrupts. The user writes a service routine to take corrective measures and provide
an indication to inform the user that an exceptional condition has occurred.
Many microprocessors include software interrupts, or system calls. When one of these instruc-
tions is executed, the microprocessor is interrupted and serviced similarly to external or internal
interrupts. Software interrupt instructions are normally used to call the operating system. These
instructions are shorter than subroutine calJs, and no calling program is needed to know the
operating system's address in memory. Software interrupt instructions allow the user to switch
from user to supervisor mode. For some microprocessors, a sofu...,are interrupt is the only way
to call the operating system, since a subroutine call to an address in the operating system is not
allowed.
1.3.4.e.ii Interrupt Address Vector. The technique used to find the starting address of the service
routine (commonly known as the interrupt address vector) varies from one microprocessor to
another. With some microprocessors, the manufacturers define the fLXed starting address for
each interrupt. Other manufacturers use an indirect approach by defining fLXed locations
where the interrupt address vector is stored.
microprocessor saves prior to executing the service routine. This wilJ enable the user to use the
appropriate return instruction at the end of the service routine to restore the original condi-
tions upon return to the main program.
1.3.4.e.ivlnterrupt Priorities. A microprocessor is typically provided with one or more interrupt pins
on the chip. Therefore, a special mechanism is necessary to handle interrupts from several
devices that share one of these interrupt lines. There are two ways of servicing multiple
interrupts: polled and daisy chain techniques.
Polled interrupts are handled by software and therefore are slower when compared with
daisy chaining. The processor responds to an interrupt by executing one general service
routine for aU devices. The priorities of devices are determined by the order in which the
routine polls each device. The processor checks the status of each device in the general service
routine, starting with the highest-priority device to service an interrupt. Once the processor
determines the source of the interrupt, it branches to the service routine for the device.
In a daisy chain priority system, devices are connected in a daisy chain fashion to set up a
priority system. Suppose one or more devices interrupt the processor. In response, the proces-
sor pushes at least the PC and generates an interrupt acknowledge ( INTA) signal to the
highest-priority device. If this device has generated the interrupt, it will accept the INT A.
Otherwise it \'.ill pass the INTA onto the next device until INTA is accepted. Once accepted,
the device provides a means for the processor to find an interrupt address vector by using
external hardware. The daisy chain priority scheme is based on mostly hardware and is
therefore faster than the polled interrupt.
makes the INHIBIT line LOW for one clock cycle. The microprocessor is then stopped
completely for one cycle. Data transfer between the memory and l/0 takes place during this
cycle. This method is called cycle stealing because the DMA controller takes away or steals a
cycle without microprocessor recognition. Data transfer takes place over a period of time.
With interleaved DMA, the DMA controller chip takes over the system bus when the
microprocessor is not using it. For example, the microprocessor does not use the bus while
incrementing the program counter or performing an ALU operation. The DMA controller
chip identifies these cycles and allows transfer of data between the memory and l/0 device.
Data transfer takes place over a period of time for this method.
The DMA controller chip usually has at least three registers normally selected by the
controller's register select (RS) line: an address register, a terminal count register, and a status
register. Both the address and terminal count registers are initialized by the micro processor.
The address register contains the starting of the data to be transferred, and the term inal count
register contains the desired block to be transferred. The status register contains information
such as completion of DMA transfer.
It should be mentioned that while using either block transfer or cycle stealing DMA in
systems with dynamic RAMs, circuitry must be included for refreshing the dynamic RAM's
during DMA transfer.
1/0
1.3.4.h Coprocessors
In typical 8-bit microprocessors such as the Intel 8085, technology places a limit on the chip
area. As a consequence, these microprocessors include no hardware or firmware for perform-
ing scientific computations such as floating-point arithmetic, matrix manipulation, and graphic-
data processing. Therefore, users of these systems must write these programs. Unfortunately,
Introduction to Microprocessors and Microcomputer-Based Applications 33
Note that state-of-the-art 32-bit microprocessors such as the Intel 80486 and the Motorola
68040 implement coprocessor hardware such as floating point hardware and MMU on the
microprocessor chip.
From this example, it is clear that the usage of mnemonics (in our example MOV, ADD,
HLT are the mnemonics) improves the readability of our program significantly.
An assembly language program cannot be executed by a machine directly, as it is not in
binary form . Usually, we refer to a symbolic program as a source program. An assembler is
needed in order to translate an assembly language (source) program into the machine lan-
guage (object) executable by the machine. This is illustrated in Figure 1.18.
A ssembly
language Object
Program Result
Program
(text) (bin ary)
. . ______.~ I
'
Compiler I------.
data
....______,
IUniZl
______. ~ __.Result
1.5.1 Introduction
An instruction manipulates the stored data, and a sequence of instructions constitutes a
program. In general, an instruction has two components:
Op-code field
Operand field(s)
The op-code field specifies how data are to be manipulated.The op-code field may contain
data or a microprocessor register or a memory address. Consider the following instruction:
ADD Rl, RO
op-code field operand field
Assume that this microcomputer uses Rl as the source register and RO as the destination
register. The preceding instruction then adds the contents of registers RO and Rl and saves the
sum in register RO.
Depending on the number of addresses specified, one can have the following instruction
formats:
Three-operand
Two-operand
One-operand
Zero-operand
The 8-bit microprocessors include mostly one-operand instructions along with some zero-
and two-operand instructions. In 16-bit microprocessors, two-operand instructions are pre-
dominant although some zero- and one-operand instructions are present. The 32-bit micro-
processors include all four instruction formats.
The way in which a microprocessor accomplishes this task is by recognizing the addressing
mode used in the instruction. Typical addressing modes supported by the instruction sets of
popular processors will be examined.
An instruction is said to have an inherent addressing mode if it is a zero-operand instruction.
As an example, consider the zero-operand instruction CLC which clears the carry flag to zero.
Whenever an instruction contains data in the operand field, it is called an immediate mode
instruction. For example, consider the following instruction:
This instruction copies the contents of memory location 5000 in the register R2.
An instruction is said to have a register mode if it contains a register in the operand field. For
example, consider the following register mode intruction.
This instruction uses register mode for both source and destination operands.
Whenever an instruction specifies a register that holds the address of an operand, the
resulting addressing mode is known as the register indirect mode. From this definition, it
follows that the Effective Address (EA) of an operand in the register-indirect mode is the
contents of the register R. More formally, this result is written as follows:
EA = [R]
Data transfer instructions are primarily concerned with data transfers between the micro-
processor registers or between register and memory. An example is MOVE RO, Rl which
transfers the contents of register RO to register Rl.
Typical arithmetic instructions include ADD and SUBTRACT instructions. For example,
ADD RO, Rl adds the contents of RO to Rl and stores the result in Rl.
Logical instructions perform Boolean AND, OR, NOT, and EXCLUSIVE-OR operations on
a bit-by-bit basis. An example is OR RO, Rl which logically ORs the contents of RO with Rl
and places the result in Rl.
Typical program control instructions include unconditional and conditional branch and
subroutine CALL instructions. For example, JMP 2035H unconditionally branches to the 16-
bit address 2035H.
1/0 instructions perform input and output operations. An example is IN PORTA which
inputs the contents of an 1/0 port called Port A into a microprocessor register such as the
accumulator.
routines necessary to interface between the user and the mass storage unit. When the user
requests a file by a specific file name, the operating system finds the program stored on disk
by the file name and loads it into main memory. More advanced development systems contain
memory management software that protects a user's files from unauthorized modification by
another user. This is accomplished via a unique user identification code called USER ID. A user
can only access files that have the user's unique code.
The equipment listed above comprises a basic development system, but most systems have
other devices such as printers and PROM programmers attached . A printer is needed to
provide the user with a hard copy record of the program under development.
After the application system software has been completely developed and debugged, it needs
to be permanently stored for execution in the target hardware. The EPROM programmer takes
the machine code and programs it into an EPROM. Erasable/Programmable Read Only
Memories (EPROMs) are more generally used in system development as they may be erased
and reprogrammed if the program changes. EPROM programmers usually interface to circuits
particularly designed to program a specific PROM. These interface boards are called person-
ality cards and are available for all the popular PROM configurations.
Most development systems support one or more in-circuit emulators (ICEs). The ICE is one
of the most advanced tools for microprocessor hardware development. To use an ICE, the
microprocessor chip is removed from the system under development (called the target
processor) and the emulator plugged into the microprocessor socket. The ICE will function-
ally and electrically act identically to the target processor with the exception that the ICE is
under the control of development system software. In this manner the development system
may exercise the hardware that is being designed and monitor all status information avail-
able about the operation of the target processor. Using an ICE, processor register contents
may be displayed on the CRT and operation of the hardware observed in a single-stepping
mode. In-circuit emulators can find hardware and software bugs quickly that might take
many hours using conventional hardware testing methods.
Architectures for development systems can be generally divided into two categories: the
master/slave configuration and the single-processor configuration . In a master/~lave configu-
ration, the master (host) processor controls all development functions such as editing, assem-
bling, and so on. The master processor controls the mass storage device and proces~es aU 1/0
(CRT, printer).
The software for the development systems is written for the m ;1ster proces~or which is
usually not the same as the slave (target) processor. The slave microprocessor is typically
connected to the user prototype via a 40-pin connector (the number varies with the processor)
which links the slave processor to the master processor.
Some development systems such as the HP 64000 completely :>eparate the system bus from
the emulation bus and therefore use a separate block of memory for emulation . This separa-
tion allows passive monitoring of the software executing on the target processor without
stopping the emulation process. A benefit of the separate emulation [Kilities allows the master
processor to be used for editing, assembling, and so on, while the slave proce~sor continues the
emulation. A designer may therefore start an emulation running, exit the emulator program,
and at some future time return to the emulation program.
Another advantage of the separate bus architecture is that an operating system needs to be
written only once for the master proce~sor and wi!J be med no matter what type of slave
processor is being emulated. When a new slave proce~sor is to be emulated, only the emulator
probe needs to be changed.
A disadvantage of the master/slave architecture is that it is expensive. In single-processor
architecture, only one processor is used for system operation and target emulation. The single
processor does both jobs of executing system software as weU as acting as the target processor.
Since there is only one processor involved, the system software must be rewritten for each type
40 Microprocessors and Microcomputer-Based System Design, 2nd Edition
of processor that is to be emulated. Since the system software must reside in the same memory
used by the emulator, not all memory will be available to the emulation process, which may
be a disadvantage when large prototypes are being developed. The single processor systems are
inexpensive.
The programs provided for microprocessor development are the operating system, editor,
assembler, linker, compiler, and debugger.
The operating system is responsible for executing the user's commands. The operating
system (such as UNIX) handles 1/0 functions, memory management, and loading of programs
from mass storage into RAM for execution.
The editor allows the user to enter the source code (either assembly language or some high-
level language) into the development system.
Almost all current microprocessor development systems use the character-oriented editor,
more commonly referred to as the screen editor. The editor is called a screen editor because
the text is dynamically displayed on the screen and the display automatically updates any edits
made by the user.
The screen editor uses the pointer concept to point to the character(s) that need editing. The
pointer in a screen editor is called the cursor and special commands allow the user to position
the cursor to any location displayed on the screen. When the cursor is positioned, the user may
insert characters, delete characters, or simply type over the existing characters.
Complete lines may be added or deleted using special editor commands. By placing the
editor in the insert mode, any text typed will be inserted at the cursor position when the cursor
is positioned between two existing lines. If the cursor is positioned on a line to be deleted, a
single command will remove the entire line from the file.
Screen editors implement the editor commands in different fashions. Some editors use
dedicated keys to provide some cursor movements. The cursor keys are usually marked with
arrows to show the direction of cursor movement.
More advanced editors (such as the HP 64000) use soft keys. A soft key is an unmarked key
located on the keyboard directly below the bottom of the CRT screen. The mode of the editor
decides what functions the keys are to perform. The function of each key is displayed on the
screen directly above the appropriate key. The soft key approach is valuable because it frees the
user from the problem of memorizing many different special control keys. The soft key
approach also allows the editor to reassign a key to a new function when necessary.
The source code generated on the editor is stored as ASCII or text characters and cannot be
executed by a microprocessor. Before the code can be executed, it must be converted to a form
acceptable by the microprocessor. An assembler is the program used to translate the assembly
language source code generated with an editor into object code (machine code) which may be
executed by a microprocessor.
Assemblers recognize four fields on each line of source code. The t!elds consist of a variable
number of characters and are identified by their position in the line. T he fields, from left to
right on a line, are the label field, the mnemonic or op-code field, the operand field, and the
comment field. Fields are separated by characters called delimiters which serve as a flag to the
assembler that one field is done and the next one is to start. Typical delimiters and their uses
are
space used to separate fields
TAB used to separate field s
used between addresses or data in the operand field
used before a comment statement
used after a label
A few typical lines of 8085 source code are
Introduction to Microprocessors and Microcomputer-Based Applications 41
As can be seen in the above example, tab keys are used instead of spaces to separate the fields
to give a more spread out line which is easier to read during debugging.
In order for the assembler to differentiate between numbers and labels, specific rules are set
up which apply to aU assemblers. A label must start with a letter. After the letter, a combination
ofletters and numbers (called alphanumerics) may be used. For example, when grouping Lines
of code by function, a common alphabetic string may be used followed by a unique number
for the label: LOOPO 1, LOOP02, LOOP 10, and so on.
A numeric quantity must start with a number, even though the number may be in hex
(which may start with a letter). Most assemblers assume that a number is expressed in the
decimal system and if another base is desired, a special code letter is used immediately
following the number. The usual letter codes used are
B binary
C octal
H hex (Motorola uses$ before the number)
To avoid confusion when hex quantities are used, a leading zero is inserted to tell the
assembler that the quantity is a number and not a label (for example, the quantity FA in hex
would be represented by OFAH in the source code).
Assembler Directives
Assembler directives are instructions entered into the source code along with the assembly
language. These directives do not get translated into object code but are used as special
instructions to the assembler to perform some special functions. The assembler will recognize
directives that assign memory space, assign addresses to labels, format the pages of the source
code, and so on.
The directive is usually placed in the op-code field . If any labels or data are required by the
directive, they are placed in the label or operand field as necessary.
Some common directives will now be discussed in detail.
a. ORIGIN (ORG). The ORG statement is used by the programmer when it is necessary to
place the program in a particular location in memory. As the assembler is translating the
source code, it keeps an internal counter (similar to the microprocessor program counter) that
keeps track of the address for the machine code. The counter is incremented automatically and
sequentially by the assembler. If the programmer wishes to alter the locations where the
machine code is going to be located, the ORG statement is used.
For example, if it is desired to have a subroutine at a particular location in memory, such
as 2000H, the statement ORG 2000H, would be placed immediately before the subroutine to
direct the assembler to alter the internal program counter.
Most assemblers will assume a starting address of zero if no ORG statement is given in the
source code.
b. EQUATE (EQU). The EQU instruction is used to assign the data value or address in the
operand field to the label in the label field. The EQU instruction is valuable because it allows
the programmer to write the source code in symbolic form and not be concerned with the
42 Microprocessors and Microcomputer-Based System Design, 2nd Edition
numeric value needed. In some cases, the programmer is developing a program without
knowing what addresses or data may be required by the hardware. The program may be
written and debugged in symbolic form and the actual data added at a later time. Using the
EQU instruction is also helpful when a data value is used several times in a program. If, for
example, a counter value was loaded at ten different locations in the program, a symbolic label
(such as COUNT) could be used and the label count defined at the end of the program. By
using this technique, if it is found during debugging that the value in COUNT must be
changed, it need only be changed at the EQU instruction and not at each of the ten locations
where it is used in the program.
c. DEFTNE BYTE (DEFB or DB). The DB instruction is used to set a memory location to a
specific data value. The DB instruction is usually used to create data tables or to preset a flag
value used in a program. As the name implies, the DB instruction is used for creating an 8-bit
value.
For example, if a table of four values, 44H, 34H, 2SH, and OD3H, had to be created at
address 2000H , the following code could be written:
ORG 2000H ; SET TABLE ADDRESS
TABLE DB 44H,34H,25H,OD3H;PRESET TABLE VALUES
The commas are necessary for the assembler to be able to differentiate between data values.
When the code is assembled, the machine code would appear as follows:
2000 44
2001 34
2002 25
2003 D3
d. DEFINE WORD (DEFW or DW). Similarly to DB, DW defines memory locations to specific
values. As the name implies, the memory allotted is in word lengths which are usually 16 bits
wide. When assigning a 16-bit value to memory locations, two 8-bit memory locations must
be used . By convention, most assemblers store the least significant byte of the 16-bit value in
the first memory location and the most significant byte of the 16-bit value in the next memory
location. This technique is sometimes referred to as Intel style, because the first microproces-
sors were developed by Intel, and this storage method is how the Intel processors store 16-bit
words .
Data tables may be created with the DW instruction, but care must be taken to remember
the order in which the 16-bit words are stored. For example, consider the following table:
ORG 2500H
DATA DW 4000H, 2300H, 4BCAH
The machine code generated for this table would appear as folJows:
2500 00
2501 40
2502 00
2503 23
2504 CA
2505 4B
Introduction to Microprocessors and Microcomputer-Based Applications 43
e. TITLE. TITLE is a formatting instruction that allows the user to name the program and have
the name appear on the source code listing. Consider the following line:
When the assembler generates the program listing, each time it starts a new page the title
MULTIPLICATION ROUTINE appears at the top of each page.
Several types of assemblers are available, the most common types are discussed below.
a. One-Pass Assembler. The one-pass assembler was the first type to be developed and is
therefore the most primitive. Very few systems use a one-pass assembler because of the
inherent problem that only backward references may be used.
In a one-pass assembler the source code is processed only once. As the source code is
processed, any labels encountered are given an address and stored in a table. Therefore, when
the label is encountered again, the assembler may look backward to find the address of the
label. If the label has not been defined yet (for example, a jump instruction that jumps
forward), the assembler issues an error message.
b. Two-Pass Assembler. In the two-pass assembles, the source code is passed twice through the
assembler. The first pass made through the source code is specifically for the purpose of
assigning an address to aU labels. When aU labels have been stored in a table with the
appropriate addresses, a second pass is made to actually translate the source code into machine
code.
The two -pass style assembler is the most popular type of assembler currently in use.
d. Cross Assemblers. A cross assembler may be of any of the types already mentioned. The
distinguishing feature of a cross assembler is that it is not written in the same language used
by the microprocessor that will execute the machine code generated by the assembler.
Cross assemblers are usually written in a high-levellanguage such as FORTRAN which wiiJ
make them machine independent. For example, an 8086 assembler may be written in FOR-
TRAN and then the assembler may be executed on another machine such as the Motorola
6800.
e. Metaassembler. The most powerful assembler is the metaassembler because it will support
many different microprocessors. The programmer merely specifies at the start of the source
code which microprocessor assembly language will be used and the metaassembler wiU trans-
late the source code to the correct machine code.
The output file from most development system assemblers is an object file. The object file
is usually relocatable code that may be configured to execute at any address . The function of
the linker is to convert the object file to an absolute file which consists of the actual machine
code at the correct address for execution. The absolute files thus created are used for debugging
and finally for programming EPROMs.
Debugging a microprocessor-based system may be divided into two categories: software
debugging and hardware debugging. Both debug processes are usually carried out separately
from each other because software debugging can be carried out on an Out-Of-Circuit-
Emulator (OCE) without having the final system hardware.
44 Microprocessors and Microcomputer-Based System Design, 2nd Edition
The usual software development tools provided with the development system are
Single-step facility
Breakpoint facility
A single-stepper simply allows the user to execute the program being debugged one instruc-
tion at a time. By examining the register and memory contents during each step, the debugger
can detect such program faults as incorrect jumps, incorrect addressing, erroneous op codes,
and so on.
A breakpoint a.llows the user to execute an entire section of a program being debugged.
There are two types ofbreakpoint systems: hardware and software. The hardware breakpoint
uses hardware to monitor the system address bus and detect when the program is executing
the desired breakpoint location. When the breakpoint is detected, the hardware uses the
processor control Jines to either halt the processor for inspection or cause the processor to
execute an interrupt to a breakpoint routine. Hardware breakpoints can be used to debug both
ROM- and RAM -based programs. Software breakpoint routines may only operate on a system
with the program in RAM because the breakpoint instruction must be inserted into the
program that is to be executed .
Single-stepper and breakpoint methods complement each other. The user m ay insert a
breakpoint at the desired point a nd let the program execute up to that point. When the
program stops at the breakpoint the user may use a single-stepper to examine the program one
instruction at a time. Thus, the user can pinpoint the error in a program.
There are t\vo main hardware debugging tools: the logic analyzer and the in-circuit emula -
tor.
Logic analyzers are usually used to debug hardware faults in a system. T he logic analyzer is
the digital version of an oscilloscope because it allows the user to view logic levels in the
hardware.
In-circuit emulators can be used to debug and integrate software and hardware.
PC- based workstations are extensively used as development systems.
The linker can now take the object code generated by the assembler and create the final
absolute code that will be executed on the target system. The emulation phase will take the
absolute code and load it into the development system RAM. From here, the program may be
debugged using breakpoints or single-stepping.
46 Microprocessors and Microcomputer-Based System Design, 2nd Edition
Motorola's 32-bit microprocessor family includes the 68020, 68030, and 68040.
Since 1988, Intel, Morotola, and others have been introducing the RISC microprocessors.
Some of these are the Intel 80960 family, the Motorola MC88100, the Apple/IBM/Motorola
PowerPC, and Digital Equipment Corporation's Alpha 21164. The 80960 and 88100 are 32-
bit microprocessors. They can directly address 4 gigabytes of memory. The Power PC family,
on the other hand, includes both 32-bit and 64-bit microprocessors. The 80960 and 88100
include a 32-bit data bus while the Power PC contains a 64-bit data bus. The PowerPc is based
on IBM PowerPC architecture and Motorola's 88100 bus interface design. These RISC micro-
processors find extensive applications in embedded controls such as laser printers.
The PowerPC 601 outperforms and under-prices the Pentium but to be successful must
build up its selection of software applications. Note that the Pentium had a flaw in its division
algorithm caused by a problem with a Lookup table used in the division. Intel recently
corrected this problem.
Tables 1.2a and 1.2b provide a brief description oflntel and Motorola's typical 16- and 32-
bit microprocessors.
Introduced October 1985 June 1988 April 1989 April 1991 March 1992 May 1993
Maximum clock speed 40 Mbz 33 Mbz 50 Mbz 25 Mhz 66 Mhz 100 Mhz
MIPS 6 2.5 20 16.5 40 112
Transistor 275,000 275 ,000 1.2 Millions 1.185 Mill ions 1.2 Millions 3.1 Millions
On-ch.ip cache memory Support Support Yes Yes Yes Yes
chips avaJiable chips avaliable
Data Bus 32-bit 16-bit 32-bit 32-bit 32-bit 64-bit
Address Bus 32-bit 24-bit 32-bit 32-bit 32-bit 32-bit
Directly Addressable 4 gigabytes 16 megabytes 4 gigabytes 4 gigabytes 4 gigabytes 4 gigabytes
Memory
Pins 132 100 168 168 168 273
Virtual Memory Yes Yes Yes Yes Yes Yes
On-chip Memory Yes Yes Yes Yes Yes Yes
Management and
..
Protection
Addressing Modes• 11 II II II 11 11
Floating-point 387DX 387SX 487SX
Maximum Clock Speed 33 Mhz (8 Mhz min.) 33 Mhz (8 Mhz min.) 33 Mhz (8 Mhz min.)
Pins 114 118 179
Address Bus 32-bit 32-bit 32-bit
Addressing Modes 18 18 18
Maximum Addressable 4 Gigabytes 4 Gigabytes 4 Gigabytes
Memory
Memory Management By interfacing the 68851 On-chip M.\1U On-chip MMU
MMU chip
Cache (on-chip) Instruction cache Instruction and data cache Instruction and data cache
Floating Point By interfacing 68881/68882 By interfacing 68881/68882 On-chip floating-point
floating-point coprocessor floating-point coprocessor hardware
chip chip
Introduction to Microprocessors and Microcomputer-Based Applications 49
systems can be very high if the performance requirements of the application need high-
performance VAX-type computers. Since the performance levels of32-bit microprocessors are
comparable to the V AX-type computer, multiple 32-bit microprocessors in a redundant
configuration outperform the V A.Xs. Thus, the 32-bit microprocessors provide efficient fault -
tolerant systems.
1.9.4 Robotics
The processing requirements of complex robots attempting to emulate human activities
exceed the capabilities of 8- and 16-bit microprocessors. With 32-bit microprocessors, it is
now feasible to design these controllers at low cost. In many cases, the microprocesso r is used
as the brain of the robot. In a typical application, the microprocessor will in put the actual arm
angle measurement from a sensor, compare it with the desired arm angle, and will then send
outputs to a motor to position the arm .
Mitsubishi manufactured the first 68020-based system robot control system.
LI7 What is the difference between software breakpoint and hardware breakpoint?
Ll9 Compare the typical features of the 16- and 32-bit microprocessors by Intel anc
Motorola.
L20 What types of applications are the RlSC microprocessors used for?
L21 Discuss floating-point data formats supported by both Intel 80387 and Motorol<
68881/6882.
References
Allison, D. R. , “A Design Philosophy for Microcomputer Architectures”, IEEE Trans. Computers.
Artwick, B. A. , Microcomputer Interfacing, Prentice-Hall, 1980.
Baer, J.-L. , Computer Systems Architecture, Computer Science Press, 1980.
Boyce, J. C. , Microprocessor and Microcomputer Basics, Prentice-Hall, 1979.
Breeding, K. , Microprocessor System Design Fundamentals, Prentice-Hall, 1995.
Brey, B. , The Motorola Microprocessor Family: 68000, 68008, 68010, 68020, 68030, and 68040, Saunders
College Publishing, 1992.
Burns, J. , “Within the 68020,” Electronics and Wireless Word, pp 209–212, February 1985; pp 103–106, March
1985.
Chi, C. S. , “Advances in Mass Storage Technology,” IEEE Computer, Vol. 15, no. 5, pp 60–74, May 1982.
Chow, C. K. , “On Optimization of Storage Hierarchies,” IBM Journal of Research and Development, pp
194–203, May 1974.
Cohn, D. L. and Melsa, J. L. , A Step by Step Introduction to 8080 Microprocessor Systems, Dilithium Press,
1977.
Cramer, W. and Kane, G. , 68000 Microprocessor Handbook, 2nd ed., Osborne/McGraw-Hill, 1986.
Danhor, K. J. and Smith, C. L. , Computing System Fundamentals: An Approach Based on Microcomputers,
Addison-Wesley, 1981.
Denning, P. J. , “Virtual Memory,” ACM Computing Surveys, Vol. 2, no. 3, pp 153–159, September 1970.
Electronic Industries Association , Washington, D.C., EIA Standard RS-232-C Interface, Electronic Industries
Association, 1969.
Faggin, F. , “How VLSI Impacts Computer Architecture,” IEEE Spectrum, pp 28–31, May 1978.
Feibus, M. and Slater, M. , “Pentium Power,” PC Magazine, April 27, 1993.
Fisher, E. and Jensen, C. W. , Pet and the IEEE 488 Bus (BPIB), Osborne/McGraw-Hill, 1979.
Friedman, A. D. , Logical Design of Digital Systems, Computer Science Press, 1975.
Garland, H. , Introduction to Microprocessor System Design, McGraw-Hill, 1979.
Gay , “6800 Family Memory Management — Part 1,” Electronic Engineering, pp 39–48, June 1986.
Gibson, G. A. and Liu, Y. , Microprocessors for Engineers and Scientists, Prentice-Hall, 1980.
Gill, A. , Machine and Assembly Language Programming of the PDP-11, 2nd ed., Prentice-Hall, 1983.
Girsline, G. , 16-Bit Modern Microcomputers, The Intel 8086 Family, Prentice-Hall, 1985.
Gladstone, B. E. , “Comparing Microcomputer Development System Capabilities,” Computer Design, pp 83–90,
February 1979.
Goody, R. W. , Intelligent Microcomputer, SRA, 1982.
Goody, R. , The Versatile Microcomputer, The Motorola Family, SRA, 1984.
Greenfield, J. D. , Practical Digital Design Using IC’s, John Wiley & Sons, 1977.
Greenfield, J. D. and Wray, W. C. , Using Microprocessors and Microcomputers: The 6800 Family, John Wiley
& Sons, 1983.
Greenfield, J. D. , Practical Digital Design Using IC’s, John Wiley & Sons, 1983.
Grinich, V. H. and Jackson, H. G. , Introduction to Integrated Circuits, McGraw-Hill, 1975.
Hall, D. V. , Microprocessors and Digital Systems, McGraw-Hill, 1980.
Hamacher, V. C. , Vranesic, Z. G. , and Zaky, S. G. , Computer Organization, McGraw-Hill, 1978
Hamacher, V. C. , Vranesic, Z. G. , and Zaky, S. G. , Computer Organization, McGraw-Hill, 1984
Harman, T. L. and Lawson, B. , The Motorola MC68000 Microprocessor Family, Prentice-Hall, 1984.
Hartman, B. , “16-Bit 68000 Microprocessor Concepts on 32-Bit Frontier,” MC 68000 Article Reprints, Motorola,
pp 50–57, March 1981.
Hayes, J. P. , Computer Architecture and Organization, McGraw-Hill, 1978.
Hayes, J. P. , Digital System Design and Microprocessors, McGraw-Hill, 1984.
Haynes, J. L. , “Circuit Design with Lotus 1–2–3,” BYTE, Vol. 10, no. 11, pp 143–156, 1985.
Hewlett-Packard , “HP 64000,” Hewlett-Packard Journal, 1980.
Hnatek, E. R. , A User’s Handbook of Semiconductor Memories, John Wiley & Sons, 1977.
Holt, C. A. , Electronic Circuits — Digital and Analog, John Wiley & Sons, 1978.
Horden, I. , “Microcontrollers Offer Realtime Robotics Control,” Computer Design, pp 98–101 October 15, 1985.
IEEE , “Technology 1994” — The Spectrum, January 1994.
IEEE , “Technology 1995” — The Spectrum, January 1995.
Intel , Microprocessors and Peripheral Handbook, Vol. 1, Microprocessors, Intel Corporation, 1988
Intel , Microprocessors and Peripheral Handbook, Vol. 2, Peripheral, Intel Corporation, 1988.
Intel , 80386 Programmer’s Reference Manual, Intel Corporation, 1986.
Intel , 80386 Hardware Reference Manual, Intel Corporation, 1986.
Intel , 80386 Advance Information, Intel Corporation, 1985.
Intel , 80387 Programmer’s Reference Manual, 1987.
Intel , Intel 486 Microprocessor Family Programmer’s Reference Manual, 1992.
Intel , Intel 486 Microprocessor Hardware Reference Manual, 1992.
Intel , i960 SA/SB Microprocessor, 1991.
Intel , Pentium Processor User’s Manual, 1993.
Intel , 8080 and 8085 Assembly Language Programming Manual, Intel Corporation, 1978.
Intel , The 8086 Family User’s Family, Intel Corporation, 1979.
Intel , Intel Component Data Catalog, Intel Corporation, 1979.
Intel , MCS-85 User’s Manual, Intel Corporation, 1978.
Intel , MCS-86 User’s Manual, Intel Corporation, 1982.
Intel , Memory Components Handbook, Intel Corporation, 1982.
Intel , SDK-85 User’s Manual, Intel Corporation, 1978.
Intel , “Marketing Communications,” The Semiconductor Memory Book, John Wiley & Sons, 1978.
Isaacson, R. et al., “The Oregon Report — Personal Computing,” selected reprints from IEEE Computer, pp
226–237.
Johnson , “A Comparison of MC68000 Family Processors,” BYTE, pp 205–218, September 1986.
Johnson, C. D. , Process Control Instrumentation Technology, John Wiley & Sons, 1977.
Johnson, R. C. , “Microsystems Exploit Mainframe Methods,” Electronics, 1981.
Kane, G. , CRT Controller Handbook, Osborne/McGraw-Hill, 1980.
Kane, G. , Hawkins, D. , and Leventhal, L. , 68000 Assembly Language Programming Osborne/McGraw-Hill,
1981.
King, T. and Knight, B. , Programming the MC68000, Addison-Wesley, 1983.
Krutz, R. L. , Microprocessors and Logic Design, John Wiley & Sons, 1980.
Krutz, R. L. , Microprocessors and Logic Design, John Wiley & Sons, 1977.
Lesea, A. and Zaks, R. , Microprocessor Interfacing Techniques, Sybex, 1978.
Leventhal, L. A. , 8080A/8085 Assembly Language Programming Osborne/McGraw-Hill, 1978.
Leventhal, L. A. , Introduction to Microprocessors: Software, Hardware Programming, Prentice-Hall, 1978.
Leventhal, L. and Walsh, C. , Microcomputer Experimentation with the Intel SDK-85, Prentice-Hall, 1980.
Lewin, M. , Logic Design and Computer Organization, Addison-Wesley, 1983.
Lipschutz, S. , Essential Computer Mathematics, Schaum Outline Series, McGraw-Hill, 1982.
MacGregor , Mothersole, Meyer , The Motorola MC68020,” IEEE MICRO, pp 101–116, August 1984.
MacGregor , “Diverse Applications Put Spotlight on 68020’s Improvements,” Electronic Design, pp 155–164,
February 7, 1985.
MacGregor , “Hardware and Software Strategies for the MC68020,” EDN, pp 163–168, June 20, 1985.
Mano, M. , Computer System Architecture, Prentice-Hall, 1983.
McCartney, Groepler , “The 32-Bit 68020’s Power Flows Fully Through a Versatile Interface,” Electronic Design,
pp 335–343, January 10, 1985.
Miller, M. , Raskin, R. , and Rupley, S. , “The Pentium that Stole Christmas,” PC Magazine, February 27, 1995.
MITS-ALTAIR , S-100 Bus, MITS, Inc., Albuquerque, NM.
Morse, S. , The 8086/8088 Primer, 2nd ed., Hayden, 1982.
Motorola , 6809 Applications Notes, Motorola Corporation, 1978.
Motorola , MC68000 User’s Manual, Motorola Corporation, 1979.
Motorola , 16-Bit Microprocessor — MC68000 User’s Manual, 4th ed., Prentice-Hall, 1984.
Motorola , MC68000 16-Bit Microprocessor User’s Manual, Motorola Corporation, 1982.
Motorola , MC68000 Supplement Material (Technical Training), Motorola Corporation, 1982.
Motorola , Microprocessor Data Material, Motorola Corporation, 1981.
Motorola , MC68020 User’s Manual, Motorola Corporation, 1985.
Motorola , “MC68020 Course Notes,” MTTA20 REV 2, July 1987.
Motorola , “MC68020/68030/88100 Audio Course Notes,” 1988.
Motorola , MC88100 Data Sheets, Motorola Corporation, 1988.
Motorola , MC68020 User’s Manual, 2nd ed., MC68020 UM/AD Rev. 1, Prentice-Hall, 1984.
Motorola , Programmer’s Reference Manual (Includes CPU 32 Instructions), 1989.
Motorola , MC68040 User’s Manual, 1989.
Motorola , Power PC 601, RISC Microprocessor User’s Manual, 1993.
Motorola Technical Summary , 32-Bit Virtual Memory Microprocessor, MC68020 BR243/D. Rev. 2, Motorola
Corporation, 1987.
Myers, G. and Budde, D. , The 80960 Microprocessor Architecture, John Wiley & Sons, 1988.
Osborne, A. , An Introduction to Microprocessors, Vol. 1, Basic Concepts, rev. ed., Osborne/McGraw-Hill, 1980;
2nd ed., 1982.
Osborne, A. and Kane, G. , The Osborne Four- and Eight-Bit Microprocessor Handbook, Osborne/McGraw-Hill,
1980.
Osborne, A. and Kane, G. , The Osborne 16-Bit Microprocessor Handbook, Osborne/McGraw-Hill, 1981.
Rafiquzzaman, M. , Microprocessors and Microcomputer Development Systems — Designing Microprocessor-
Based Systems, Harper and Row, 1984.
Rafiquzzaman, M. , Microprocessors and Microcomputer Development Systems, John Wiley & Sons, 1984.
Rafiquzzaman, M. , Microcomputer Theory and Applications with the INTEL SDK-85, 2nd ed., John Wiley &
Sons, 1987.
Rafiquzzaman, M. , Microprocessors — Theory and Applications — Intel and Motorola, Prentice-Hall, 1992.
Rafiquzzaman, M. and Chandra , Modern Computer Architecture, West, 1988.
RCA , Evaluation Kit Manual for the RCA CDP1802 COSMAC Microprocessor, RCA Solid State Division,
Somerville, NJ.
Rector, R. and Alexy, G. , The 8086 Book, Osborne/McGraw-Hill, 1980.
Reichborn-Kjennerud, G. , “Novel Methods of Integer Multiplication and Division,” BYTE, Vol. 8, no. 6, pp
364–374, June 1983.
Ripps, Mushinsky , “32-Bit Up Speeds Code Design and Execution,” EDN, pp 163–168, June 27, 1985.
Rockwell International , Microelectronic Devices Data Catalog, 1979.
Short, K. L. , Microprocessors and Programmed Logic, Prentice-Hall, 1981.
Sloan, M. E. , Introduction to Minicomputers and Microcomputers, Addison-Wesley, 1980.
Smith, J. and Weiss, S. , “Power PC 601 and Alpha 21064: A Tale of Two RISCs,” IEEE Computer, June 1994.
Solomon , “Motorola’s Muscular 68020,” Computers & Electronics, pp 74–79, October 1984.
Sowell, E. F. , Programming in Assembly Language, MACRO II, Addison-Wesley, 1984.
Starnes, T. W. , “Compact Instruction Set Gives the MC68000 Power While Simplifying Its Operation,”
MC68000 Article Reprints, Motorola, pp 43–47, March 1981.
Strauss, E. , The Waite Group, Inside the 80286, A Brady Book published by Prentice-Hall, 1986.
Stone, H. S. , Introduction to Computer Architecture, SRA, 1980.
Stone, H. S. , Microcomputer Interfacing, Addison-Wesley, 1982.
Streitmatter, G. A. and Fiore, V. , Microprocessors, Theory and Applications, Reston Publishing, 1979.
Stritter, E. and Gunter, T. , “A Microprocessor Architecture for a Changing World: The Motorola 68000,” IEEE
Computers, Vol. 12, no. 2, pp 43–52, February 1970.
Tanenbaum, A. S. , Structured Computer Organization, Prentice-Hall, 1984.
Teledyne , Teledyne Semiconductor Catalog, 1977.
Texas Instruments , The TTL Data Book, Vol. 1, 1984.
Texas Instruments , The TTL Data Book for Design Engineers, 2nd ed., 1976.
Tocci, R. J. and Laskowski, L. P. , Microprocessors and Microcomputers: Hardware and Software, Prentice-
Hall, 1979.
Triebel, W. , The 80386 DX Microprocessor, Prentice-Hall, 1992.
Twaddel , “32-Bit Extension to the 68000 Family Addresses 7 GBytes, Runs at 3 MIPS,” EDN, pp 75–77, July
12, 1984.
Wakerly, J. F. , Microcomputer Architecture and Programming, John Wiley & Sons, 1981.
Zilog , Z8000 Advance Specification, Zilog, Inc., 1978.
Zoch, B. , “68020 Dynamically Adjusts Its Data Transfers to Match Peripheral Ports,” Electronic Design, pp
219–225, January 10, 1985.
Zorpette, G. , “Microprocessors — The Beauty of 32-Bits,” IEEE Spectrum, Vol. 22, no. 9, pp 65–71, September
1985.