0% found this document useful (0 votes)
1 views25 pages

Microprocessors Notes Unit I & II

Uploaded by

KSA TEXTILE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views25 pages

Microprocessors Notes Unit I & II

Uploaded by

KSA TEXTILE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

UNIT I

Introduction to Microprocessors & 8085 Assembly Language Programming


Microprocessors
Instruction set and computer languages-8085 programming model-Instruction
Classification-Instruction-Data format and storage-Execute a simple program-8085 instruction
set

Microprocessors
A microprocessor is a multipurpose, programmable, clock-driven, register-based electronic
device that reads binary instructions from a storage device called memory, accepts binary data
as input and processes data according to those instructions, and provides results as output.

A Microprocessor as A Programmable Device

The fact that the microprocessor is programmable means it can be instructed to perform
given tasks within its capability. For example, an instruction for adding two numbers may look
like a group of eight binary digits, such as 1000 0000, These instructions are simply a pattern
of Os and 1s. The user (programmer) selects instructions from the list and determines the
sequence of execution for a given task. These instructions are entered or stored in storage,
called memory, which can be read by the microprocessor,

Microprocessor as a CPU (MPU)

We can also view the microprocessor as a primary component of a computer,


Traditionally, the computer is represented in block diagram as shown in Figure | .2(a). The
block diagram shows that the computer has four components: memory, input, output, and the
central processing unit (CPU), which consists of the arithmetic/logic unit (ALU) and the
control unit, The CPU contains various registers to store data, the ALU to perform arithmetic
and logical operations, instruction decoders, counters, and control lines. The CPU reads
instructions from the memory and performs the tasks specified. It communicates with
input/output devices either to accept or to send data. These devices are also known as
peripherals. The CPU is the primary and central player in communicating with devices such as
memory, input, and output, However, the timing of the communication process is controlled
by the group of circuits called the control unit.
Instruction set and computer languages
Microprocessors recognize and operate in binary numbers; However, each
microprocessor has its own binary words, meanings, and language. The words are formed by
combining a number of bits for a given machine. The word (or word length) is defined as the
number of bits the microprocessor recognizes and processes at a time. The word length ranges
from four bits for small, microprocessor-based systems to 64 bits for high-speed large
computers. Another term commonly used to express word length is byte. A byte is defined as
a group of eight bits, For example, a 16-bit microprocessor has a word length equal to two
bytes. The term nibble, which stands for a group of four bits, is found also in popular computer
magazines and books. A byte has two nibbles. Each machine has its own set of instructions
based on the design of its CPU or of its microprocessor, To communicate with the computer,
one must give instructions in binary language (machine language), Because it is difficult for
most people to write programs in sets of 0 s and 1s, computer manufacturers have devised
English-like words to represent the binary instructions of a machine. Programmers can write
programs, called assembly language programs, using these words. Because an assembly
language is specific to a given machine, programs written in assembly language are not
transferable from one machine to another. To circumvent this limitation, such general-purpose
languages as BASIC and FORTRAN have been devised; a program written in these languages
can be machine-in- dependent, These languages are called high-level languages.

The microprocessor design engineer selects combinations of bit patterns and gives a
specific meaning to each combination by using electronic logic circuits; this is called an
instruction. Instructions are made up of one word or several words. The set of instructions
designed into the machine makes up its machine language—a binary language, composed of
Os and |s—that is specific to each computer 8085 Machine Language

The 8085 is a microprocessor with 8-bit word length: its instruction set (or language)
is designed by using various combinations of these eight bits. The 8085 is an improved version
of the earlier processor 80804.

For example:

0011 1100 is an instruction that increments the number in the register called the accumulator
by one.
1000 0000 is an instruction that adds the number in the register called B to the number in the
accumulator, and keeps the sum in the accumulator.

8085 Assembly Language


Even though the instructions can be written in hexadecimal code, it is still difficult to
understand a program written in hexadecimal numbers. Therefore, each manufacturer of a
microprocessor has devised a symbolic code for each instruction, called a mnemonic. The
mnemonic for a particular instruction consists of letters that suggest the operation to be
performed by that instruction,

For example, the binary code 0011 1100 of the 8085 microprocessor is represented by
the mnemonic INR A:
INR A INR. stands for increment, and A represents the accumulator. This symbol suggests
the operation of incrementing the accumulator contents by one.

Similarly, the binary code 1000 0000 (80), or 80H) is represented as ADD B ADD stands for
addition, and B represents the contents in register B. This symbol suggests the addition of the
contents in register B and the contents in the accumulator.

Machine language and assembly language are microprocessor-specifies and are both
considered low-level languages.

High-Level Languages

Programming languages that are intended to be machine-independent are called high-


level languages. These include such languages as BASIC, PASCAL, C, C-+4., and Java, all of
which have certain sets of rules and draw on symbols and conventions from English,
Instructions written in these languages are known as statements rather than mnemonics, A
program written in BASIC for a microcomputer with the 8085 microprocessor can generally
be run on another microcomputer with a different microprocessor.
The compiler or interpreter then translates the source code into the machine language
compatible with the microprocessor being used in the system. This translation in the machine
language is called the abject code. Each microprocessor needs its own compiler or an
interpreter for each high-level language.
The primary difference between a compiler and an interpreter lies in the process of
generating machine code. The compiler reads the entire program first and translates it into the
object code that is executed by the microprocessor. On the other hand, the interpreter reads one
instructional a time, produces its object code (a sequence of machine actions), and executes the
instruction before reading the next instruction.

8085 programming model


A simplified hardware model of a microprocessor as a part of the microprocessor-based
system (Figure 1.3). It showed three components: ALU, register array, and control, Figure 2.1
shows a hardware model and a programming model specific to the 8085 microprocessor.

8085 Hardware Model

The hardware model in Figure 2.1(a) shows two major segments, One segment includes
the arithmetic/logic unit (ALU) and an 8-bit register called an accumulator, instruction decoder,
and flags. The second segment shows 68-bit and 16-bit registers. Both segments are connected
with various internal connections called an internal bus.
The arithmetic and logical operations are performed in the ALU. Results are stored in
the accumulator, and flip-flops, called flags, are set or reset to reflect the results (see Figure 2.
1a), There are three buses: a 16-bit unidirectional address bus, an 8-bil bidirectional data bus,
and a control bus.
8085 Programming Model

The programming model consists of some segments of the ALU and the registers. This
model does not reflect the physical structure of the 8085 but includes the information that is
critical in writing assembly language programs. The model includes six registers, one
accumulator, and one flag register, as shown in Figure 2.1(b). In addition, it has two 16-bit
registers: the stack pointer and the program counter. They are described briefly as follows.

REGISTERS

The 8085 has six general-purpose registers to store 8-bit data; these are identified as B,
C, D, E, H, and L, as shown in Figure 2.1(b). They can be combined as register pairs— BC,
DE, and HL—to perform some 16-bit operations. The programmer can use these registers to
store or copy data into the registers by using data copy instructions,

ACCUMULATOR

The accumulator is an 8-bit register that is part of the arithmetic/logic unit (ALU), This
register is used to store 8-bit data and to perform arithmetic and logical operations. The result
of an operation is stored in the accumulator. The accumulator is also identified as register A.

FLAGS

The ALU includes five flip-flops, which are set or reset after an operation according to
data conditions of the result in the accumulator and other registers. They are called Zero (Z),
Carry (CY), Sign (8), Parity (P), and Auxiliary Carry (AC) flags; they are listed in Table 2.1
and their bit positions in the flag register are shown in Figure 2.1(c). The most commonly used
flags are Zero, Carry, and Sign. The microprocessor uses these flags to test data conditions.
These flags have critical importance in the decision-making process of the microprocessor, The
conditions (set or reset) of the flags are tested through software instructions, For example, the
instruction JC (Jump On Carry) is implemented to change the sequence of a program when the
CY flag is set. The thorough understanding of flags is essential in writing assembly language
programs.

PROGRAM COUNTER (PC) AND STACK POINTER (SP)*


These are two 16-bit registers used to hold memory addresses. The size of these
registers is 16 bits because the memory addresses are 16 bits, The microprocessor uses the PC
register to sequence the execution of the instructions. The function of the program counter is
to point to the memory address from which the next byte is to be fetched. When a byte (machine
code) is being fetched, the program counter is incremented by one to point to the next memory
location, The stack pointer is also a 16-bit register used as a memory pointer. It points to a
memory location in R/W memory, called the stack. The beginning of the stack is defined by
loading a 16-bit address in the stack pointer.

INSTRUCTION CLASSIFICATION

The 8085 instructions can be classified into the following five functional categories:
data transfer (copy) operations, arithmetic operations, logical operations, branching
operations, and machine-control operations.

DATA TRANSFER (COPY) OPERATIONS

This group of instructions copies data from a location called a source to another
location, called a destination, without modifying the contents of the source. In technical
manuals, the term data transfer is used for this copying function.

The various types of data transfer (copy) are listed below together with examples of each
type:

Types Examples
Between registers Copy the contents of register B into register
D.
Specific data byte to a register or a memory Load register B with the data byte 32H.
location
Between a memory location and a register From the memory location 2000H to
register B.
Between an I/O device and the accumulator. From an input keyboard to the accumulator.

ARITHMETIC OPERATIONS

These instructions perform arithmetic operations such as addition, subtraction, increment,


and decrement.

Addition—Any 8-bit number, or the contents of a register, or the contents of a memory location
can be added to the contents of the accumulator and the sum is stored in the accumulator.

Subtraction—Any 8bit number, or the contents of a register, or the contents of a memory


location can be subtracted from the contents of the accumulator and the results stored in the
accumulator.

Increment/Decrement—The 8-bit contents of a register or a memory location can be


incremented or decremented by 1. Similarly, the 16-bit contents of a register pair (such as BC)
can be incremented or decremented by |. These increment and decrement operations differ from
addition and subtraction in an important way; i.e., they can be performed in any one of the
registers or in a memory location.

LOGICAL OPERATIONS
These instructions perform various logical operations with the contents of the accumulator,

AND, OR, Exclusive-OR—Any 8-bit number, or the contents of a register, or of a memory


location can be logically ANDed, ORed, or Exclusive-ORed with the contents of the
accumulator. The results are stored in the accumulator,

Rotate—Each bit in the accumulator can be shifted either left or right to the next position,

Compare—Any 8-bit number, or the contents of a register, or a memory location can be


compared for equality, greater than, or less than, with the contents of the accumulator.

Complement—The contents of the accumulator can be complemented; all Os are replaced by


Is and all Is are replaced by Os,

BRANCHING OPERATIONS

This group of instructions alters the sequence of program execution either conditionally
or unconditionally.

Jump—Conditional jumps are an important aspect of the decision-making process in


programming. These instructions test for a certain condition (e.g., Zero or Carry flag) and alter
the program sequence when the condition is met. Im addition, the instruction
set includes an instruction called unconditional jump,

Call, Return, and Restart—These instructions change the sequence of a program either by
calling a subroutine or returning from a subroutine. The conditional Call and Return
instructions also can test condition flags.

MACHINE CONTROL OPERATIONS


These instructions control machine functions such as Halt, Interrupt, or do nothing.

INSTRUCTION, DATA FORMAT AND STORAGE

An instruction is a command to the microprocessor to perform a given task on specified data.


Each instruction has two parts: one is the task to be performed, called the operation code
(opcode), and the second is the data to be operated on, called the operand. The operand (or
data) can be specified in various ways. It may include 8-bit (or 16-bit) data, an internal register,
a memory location, or an 8-bit (or 16-bit) address. In some instructions, the operand is implicit.
Instruction Word Size

The 8085 instruction set is classified into the following three groups according to word
size or byte size.

In the 8085, “byte” and “word” are synonymous because it is an 8-bil microproces-
sor, However, instructions are commonly referred to in terms of bytes rather than words,

I. |-byte instructions
2. 2-byte instructions
3, 3-byte instructions

ONE-BYTE INSTRUCTIONS
A 1-byte instruction includes the opcode and the operand in the same byte. for example:

TWO-BYTE INSTRUCTIONS
In a 2-byte instruction, the first byte specifies the operation code and the second byte specifies
the operand. For example:

THREE-BYTE INSTRUCTIONS

In a 3-byte instruction, the first byte specifies the opcode, and the following two bytes specify
the 16-bit address, Note that the second byte is the low-order address and the third byte is the
high-order address. For example:
Data Format
In 8-bit processor systems, commonly used codes and data formats are ASCII, BCD, signed
integers, and unsigned integers. They are explained as follows.

ASCII Code—This is a 7-bit alphanumeric code that represents decimal numbers, English
alphabets, and nonprintable characters such as carriage return. Extended ASCII is an 8-bit code,
The additional numbers (beyond 7-bit ASCII code) represent graphical characters.

BCD Code—The term BCD stands for binary-coded decimal; it is used for decimal numbers,
The decimal numbering system has ten digits, 0 to 9. Therefore, we need only four bits to
represent ten digits from 0000 to1001.

Signed Integer—A signed integer is either a positive number or a negative number. In an 8-bit
processor, the most significant digit, D1, is used for the sign; 0 represents the positive sign and
1 represents the negative sign. The remaining seven bits, D6 – D0, represent the magnitude of
an integer.

Unsigned Integers—An integer without a sign can be represented by all the 8 bits in a
microprocessor register. Therefore, the largest number that can be processed at one time is
FFH.

INSTRUCTION AND DATA STORAGE: MEMORY


The term memory is a misnomer; it is a storage of binary bits. Memory chips used in most
systems are nothing but 8-bit registers stacked one above the other as shown in our memory
model in Figure 2,2, It includes only four registers, and each register can store 8 bits. This chip
can be referred to as a 4-byte or 32 (4 * 8) bits memory chip. It has two address lines, Ag and
A,, to identify four registers, 8 data lines to store 8 bits, and three timing or control signals:
Read (RD), Write (WR), and Chip Select (CS); all control signals are designed to be active
low, indicated by bars over the symbols. ‘The processor can select this chip and identify its
register, and store (Write) or access (Read) 8 bits at a time, Figure 2.2 shows only four registers
to simplify the explanation; in reality, the size of a memory chip is in kilo- or megabytes, The
memory addresses assigned to these registers are determined by the interfacing logic used in
the system.
EXECUTE A SIMPLE PROGRAM
A program is a sequence of instructions written to tell a computer to perform a specific
function. The instructions are selected from the instruction set of the microprocessor, To write
a program, divide a given problem in small steps in terms of the operations the 8085 can
perform, then translate these steps into instructions, Writing a simple program of adding two
numbers in the 8085 language is illustrated below,

Illustrative Program: Adding Two Hexadecimal Numbers

PROBLEM STATEMENT
Write instructions to load the two hexadecimal numbers 32H and 48H in registers A and B,
respectively. Add the numbers, and display the sum at the LED output port PORT.

PROBLEM ANALYSIS

1. Load the numbers in the registers.


2, Add the numbers.
4. Display the sum at the output port PORT.

FLOWCHART

The steps listed in the problem analysis and the sequence can be represented in a block diagram,
called a flowchart. Figure 2.3 shows such a flowchart representing the above steps. This is a
simple flowchart, and the steps are self-explanatory.
ASSEMBLY LANGUAGE PROGRAM

To write an assembly language program, we need to translate the blocks shown in the flowchart
into 8085 operations and then, subsequently, into mnemonics. By examining the blocks, we
can classify them into three types of operations: Blocks | and 3 are copy operations; Block 2 is
an arithmetic operation, and Block 4 is a machine-control operation, To translate these steps
into assembly and machine languages, you should review the instruction set. The translation of
each block into mnemonics with comments is shown as follows:

FROM ASSEMBLY LANGUAGE TO HEX CODE

To convert the mnemonics into Hex code, we need to look up the code in the 8085 instruction
set; this is called either manual or hand assembly,
STORING IN MEMORY AND CONVERTING FROM HEX CODE TO BINARY CODE

To store the program in R/W memory of a single-board microcomputer and display the output,
we need to know the memory addresses and the output port address. Let us assume that R/W
memory ranges from 2000H to 20FFH, and the system has an LED output port with the address
O1H,

EXECUTING THE PROGRAM

To execute the program, we need to tell the microprocessor where the program begins by
entering the memory address 2000H. Now, we can push the Execute key (or the key with a
similar label) to begin the execution. As soon as the Execute function key is pushed, the
microprocessor loads 2000H in the program counter, and the program control is transferred
from the Monitor program to our program. The microprocessor begins to read one machine
code at a time, and when it fetches the complete instruction, it executes that instruction.

8085 INSTRUCTION SET

The 8085 microprocessor instruction set has 74 operation codes that result in 246
instructions, The set includes all the 8080A instructions plus two additional instructions (SIM
and RIM, related to serial 1/0). the frequently used instructions listed below,*

The following notations are used in the description of the instructions.


R = 8085 8-bit register (A, B, C, D, E, H, L)
M = Memory register (location)
Rs = Register source
Rd = Register destination (A, B, C, D, E, H, L)
Rp = Register pair (BC, DE, HL, SP)
( ) = Contents of

1. Data Transfer (Copy) Instructions. These instructions perform the following six operations.

* Load an 8-bil number in a register * Load 16-bit number in a register pair


* Copy from register to register * Copy between register and memory
* Copy between I/O and accumulator * Copy between registers and stack memory
2. Arithmetic Instructions, The frequently used arithmetic operations are:

* Add * Subtract * Increment (Add 1) * Decrement (Subtract 1)


3. Logic and Bit Manipulation Instructions. These instructions include the following
operations:

* AND * OR * X-OR (Exclusive OR) * Compare * Rotate Bits


This set of instructions is a representative sample; it does not include various instructions
related to 16-bit data operations, additional jump instructions, and conditional Call and Return
instructions.
UNIT-II
8085 Microprocessor architecture
Microprocessor Architecture and its operations, Memory, I/O Devices, -8085 MPU-8085 based
microcomputer-memory interfacing-8155-memory segment Interfacing-Interfacing I/O
devices: Basics- Interfacing input and output devices-memory mapped I/O

Microprocessor Architecture and its operations


The microprocessor has a set of instructions, designed internally, to manipulate data and
communicate with peripherals, this process of data manipulation and communication is
determined by the logic design of the microprocessor, called the architecture.

The microprocessor can be programmed to perform functions on given data by selecting


necessary instructions from its set. These instructions are given to the microprocessor by
writing them into its memory. Writing (or entering) instructions and data is done through an
input device such as a keyboard, The microprocessor reads or transfers one instruction at a
time, matches it with its instruction set, and performs the data manipulation indicated by the
instruction. The result can be stored in memory or sent to such output devices as LEDs or a
CRT terminal. In addition, the microprocessor can respond to external signals. It can be
interrupted, reset, or asked to wait to synchronize with slower peripherals. All the various
functions performed by the microprocessor can be classified in three general categories;

• Microprocessor-initiated operations
• Internal operations
• Peripheral (or externally initiated) operations

the term micro processing unit (MPU) ts defined here as a group of devices that can perform
these functions with the necessary set of control signals. This term is similar to the term central
processing unit (CPU).

Microprocessor-Initiated Operations and 8085 Bus

The MPU performs primarily four operations:*

1, Memory Read: Reads data (or instructions) from memory,


2. Memory Write: Writes data (or instructions) into memory,
3. I/O Read: Accepts data from input devices.
4. I/O Write: Sends data to output devices.

All these operations are part of the communication process between the MPU and peripheral
devices (including memory). To communicate with a peripheral (or a memory location), the
MPU needs to perform the following steps:

Step 1: Identify the peripheral or the memory location (with its address).
Step 2: Transfer binary information (data and instructions),
Step 3: Provide timing or synchronization signals.
The 8085 MPU performs these functions using three sets of communication lines
called buses: the address bus, the data bus, and the control bus

ADDRESS BUS
The address bus is a group of 16 lines generally identified as Ap to Ays. The address bus is
unidirectional: bits flow in one direction—from the MPU to peripheral devices. The MPU uses
the address bus to perform the first function: identifying a peripheral or a memory location
(Step 1).

In a computer system, each peripheral or memory location is identified by a binary number,


called an address, and the address bus is used to carry a 16-bit address.

DATA BUS
The data bus is a group of eight lines used for data flow (Figure 3.1).* These lines are
bidirectional—data flow in both directions between the MPU and memory and peripheral
devices. The MPU uses the data bus to perform the second function: transferring bi-
nary information

CONTROL BUS
The control bus is comprised of various single lines that carry synchronization signals, The
MPU uses such lines to perform the third function: providing timing signals (Step 3).

The term bus, in relation to the control signals, is somewhat confusing. These are not groups
of lines like address or data buses, but individual lines that provide a pulse to indicate an MPU
operation,

Internal Data Operations and the 8085 Registers

The internal architecture of the 8085 microprocessor determines how and what operations
can be performed with the data, These operations are:

1. Store 8-bit data.


2, Perform arithmetic and logical operations.
3. Test for conditions,
4, Sequence the execution of instructions.
5. Store data temporarily during execution in the defined R/W memory locations called
the stack.

To perform these operations, the microprocessor requires registers, an arithmetic/logic unit


(ALU) and control logic, and internal buses (paths for information flow), Figure 3.3 (same as
Figure 2.1{b); it is repeated here for reference) shows the programming model of the 8085
displaying the internal registers and the accumulator,

Peripheral or Externally Initiated Operations

External devices (or signals) can initiate the following operations, for which individual pins on
the microprocessor chip are assigned: Reset, Interrupt, Ready, Hold.

MIGROPROCESSOR ARCHITECTURE AND MICROCOMPUTER SYSTEMS

Reset: When the reset pin is activated by an external key (also called a reset key), all internal
operations are suspended and the program counter is cleared (it holds OOOOH), Now the
program execution can again begin at the zero memory address.

Interrupt: The microprocessor can be interrupted from the normal execution of instructions and
asked to execute some other instructions called a service routine (for example, emergency
procedures). The microprocessor resumes its operation after completing the service routine (see
Chapter 12),

Ready: The 8085 has a pin called READY. If the signal at this READY pin is low, the
microprocessor enters into a Wait state. This signal is used primarily to synchronize slower
peripherals with the microprocessor.

Hold: When the HOLD pin is activated by an external signal, the microprocessor relinquishes
control of buses and allows the external peripheral to use them, For example, the HOLD signal
is used in Direct Memory Access (DMA) data transfer ().These operations are listed here to
provide an overview of the capabilities of the 8085.

MEMORY

Memory is an essential component of a microcomputer system; it stores binary instructions and


data for the microprocessor. There are various types of memory, which can be classified in two
groups: prime (or main) memory and storage memory. Two examples of prime memory:
Read/Write memory (R/WM) and Read-Only memory (ROM). Magnetic tapes or disks can be
cited as examples of storage memory. First, we will focus on prime memory and then, briefly
discuss storage memory when we examine various types of memory.

The R/W memory is made of registers, and each register has a group of flip-flops or field-effect
transistors that store bits of information; these flip-flops are called memory cells. The number
of bits stored in a register is called a memory word memory devices (chips) are available in
various word sizes, The user can use this memory to hold programs and store data, On the other
hand, the ROM stores information permanently in the form of diodes; the group of diodes can
be viewed as a register. In a memory chip, all registers are arranged in a sequence and identified
by binary numbers called memory addresses. To communicate with memory, the MPU should
be able to

• select the chip,


• identify the register, and
• read from or write into the register,

The MPU uses its address bus to send the address of a memory register and uses the data bus
and control lines to read from or write into that register.

INPUT AND OUTPUT (I/O) DEVICES

Input/output devices are the means through which the MPU communicates with “the outside
world.” The MPU accepts binary data as input from devices such as keyboards and A/D
converters and sends data to output devices such as LEDs or printers. There are two different
methods by which I/O devices can be identified: one uses an 8-bit address and the other uses a
16-bit address, These methods are described briefly in the following sections.

I/Os with 8-Bit Addresses (Peripheral-Mapped I/O)

In this type of I/O, the MPU uses eight address lines to identify an input or an output de-
vice; this is known as peripheral-mapped I/O (also known as /O-mapped I/O), This is an
8-bit numbering system for I/Os used in conjunction with Input and Output instructions.
This is also known as I/O space, separate from memory space, which is a 16-bit number-
ing system. The eight address lines can have 256 (2° combinations) addresses: thus, the
MPU can identify 256 input devices and 256 output devices with addresses ranging from
00H to FFH.
The steps in communicating with an I/O device are similar to those in communicating with
memory and can be summarized as follows:

1. The MPU places an 8-bit address on the address bus, which is decoded by external de-
code logic

2, The MPU sends a control signal (1/O Read or I/O Write) and enables the I/O device,

3. Data are transferred using the data bus,

I/Os with 16-Bit Addresses (Memory-Mapped I/O)

In this type of I/O, the MPU uses 16 address lines to identify an I/O device; an I/O is connected
as if it is a memory register. This is known as memory-mapped I/O, The MPU uses the same
control signal (Memory Read or Memory Write) and instructions as those of memory. In some
microprocessors, such as the Motorola 6800, all I/Os have 16-bit addresses; I/Os and memory
share the same memory map (64<). In memory-mapped I/O, the MPU follows the same steps
as if it is accessing a memory register.

THE 8085 MPU


The term micro processing unit (MPU) is similar to the term central processing unit (CPU)
used in traditional computers, We define the MPU as a device or a group of devices (as a unit)
that can communicate with peripherals, provide timing signals, direct data flow, and perform
computing tasks as specified by the instructions in memory. The unit will have the necessary
lines for the address bus, the data bus, and the control signals, and would require only a power
supply and a crystal (or equivalent frequency determining components) to be completely
functional.

The 8085 Microprocessor

The 8085A (commonly known as the 8085) is an 8-bit general-purpose microprocessor capable
of addressing 64K of memory. The device has forty pins, requires a +5 V single power supply,
and can operate with a 3-MHz single-phase clock. The 8085A-2 version can operate at the
maximum frequency of 5 MHz. The 8085 is an enhanced version of its predecessor, the 8080A;
its instruction set is upward-compatible with that of the 8080A, meaning that the 8085
instruction set includes all the 8O080A instructions plus some additional ones.
Figure 4.1 shows the logic pinout of the 8085 microprocessor, All the signals can be classified
into six groups: (1) address bus, (2) data bus, (3) control and status signals, (4) power supply
and frequency signals, (5) externally initiated signals, and (6) serial I/O ports,

ADDRESS BUS
The 8085 has 16 signal lines (pins) that are used as the address bus; however, these lines are
split into two segments: A15—A8 and AD7-AD0. The eight signal lines, A15—A8, are
unidirectional and used for the most significant bits, called the high-order address, of a 16-bit
address. The signal lines AD7—AD0 are used for a dual purpose.

MULTIPLEXED ADDRESS/DATA BUS

The signal lines AD1—AD8 are bidirectional: they serve a dual purpose. They are used as the
low-order address bus as well as the data bus. In executing an instruction, during the earlier
part of the cycle, these lines are used as the low-order address bus, During the later part of the
cycle, these lines are used as the data bus. (This is also known as multiplexing the bus.)
However, the low-order address bus can be separated from these signals by using a latch.

CONTROL AND STATUS SIGNALS

This group of signals includes two control signals (RD and WR), three status signals (IO/M,
S1, and S0) to identify the nature of the operation, and one special signal (ALE) to indicate the
beginning of the operation, These signals are as follows:

ALE—Address Latch Enable: This is a positive going pulse generated every time the 8085
begins an operation (machine cycle);
RD—Read: This is a Read control signal (active low).
WR—Write: This is a Write control signal (active low).
I0/M: This is a status signal used to differentiate between /O and memory operations.
S1 and S0: These status signals, similar to 1O/M, can identify various operations, but
they are rarely used in small systems.

POWER SUPPLY AND CLOCK FREQUENCY


The power supply and frequency signals are as follows:

Vcc: +5 V power supply.


Vss: Ground Reference.
X1, X2: A crystal (or RC, LC network) is connected at these two pins.
CLK (OUT)—Clock Output

AN 8085-BASED MICROCOMPUTER

A general microcomputer system was illustrated in Figure 3.15, in the last chapter, after our
discussion of the 8085 microprocessor and the interfacing devices, we can expand the system
to include more details, as shown in Figure 4.9. The system includes interfacing devices such
as buffers, decoders, and latches.
The 8085 MPU module (Figure 4.9) includes devices such as the 8085 microprocessor, an octal
latch, and logic gates, as shown previously in Figure 4.6, The octal latch demultiplexes the bus
AD7—AD0 using the signal ALE, and the logic gates generate the necessary control signals.
Figure 4.9 shows the demultiplexed address bus, the data bus, and the four active low control
signals: MEMR, MEMW, IOR, and LOW. In addition, to increase the driving capacity of the
buses, a unidirectional bus driver is used for the address bus and a bidirectional bus driver is
used for the data bus, Now we can examine various operations the 8085 microprocessor
performs in terms of machine cycles and T-states.

MEMORY INTERFACING

Memory is an integral part of a microcomputer system, While executing a program, the


microprocessor needs to access memory quite frequently to read instruction codes and data
stored in memory; the interfacing circuit enables that access. Memory has certain signal
requirements to write into and read from its registers. Similarly, the microprocessor initiates a
set of signals when it wants to read from and write into memory, The interfacing process
involves designing a circuit that will match the memory requirements with the microprocessor
signals.

Memory Structure and Its Requirements

Read/Write memory (R/WM) is a group of registers to store binary information, Figure


4.1 1(a) shows a typical R/W memory chip; it has 2048 registers and each register can store
eight bits indicated by eight input and eight output data lines.* The chip has 11 address lines
Ajg—Ag, one Chip Select (CS), and two control lines: Read (RD) to enable the output buffer
and Write (WR) to enable the input buffer. Figure 4.11 (a) also shows the internal decoder to
decode the address lines, Figure 4.1 1(b) shows the logic diagram of a typical EPROM
(Erasable Programmable Read-Only Memory) with 4096 (4K) registers. It has 12 address lines
A,;—Ag, one Chip Select (CS), and one Read control signal. This chip must be programmed
(written into) before it can be used as a read-only memory, Figure 4,11(b) also shows a quartz
window on the chip that is used to expose the chip to ultraviolet rays for erasing the program.
Once the chip is programmed, the window is covered with opaque tape to avoid accidental
erasing. For interfacing the R/W memory, Figure 4.1 1{a), and the EPROM, Figure 4.11(b),
the process is similar; the only difference is that the EPROM does not require the WR signal.

Basic Concepts in Memory Interfacing

The primary function of memory interfacing is that the microprocessor should be able to read
from and write into a given register of a memory chip. Recall from Chapter 3 that to perform
these operations, the microprocessor should

1. be able to select the chip.


2. identify the register.
3. enable the appropriate buffer.

Let us examine the timing diagram of the Memory Read operation (Figure 4.12) to understand
how the 8085 can read from memory. Figure 4,12 is the M, cycle of Figure 4.10 except that the
address bus is demultiplexed. We could also use the M, cycle to illustrate these interfacing
concepts.

1. The 8085 places a 16-bit address on the address bus, and with this address only one register
should be selected. For the memory chip in Figure 4.11 (a), only 11 address lines are required
to identify 2048 registers. Therefore, we can connect the low-order address lines Ajg-Ag of the
8085 address bus to the memory chip. The internal decoder of the memory chip will identify
and select the register for the EPROM, Figure 4.1 1(a).
2. The remaining 8085 address lines (Ajs-A,,) should be decoded to generate a Chip Select
(CS) signal unique to that combination of address logic (illustrated in Examples 4.3 and 4.4),
=a

3. The 8085 provides two signals—IO/M and RD—to indicate that it is a memory read
operation. The IO/M and RD can be combined to generate the MEMR (Memory Read) control
signal that can be used to enable the output buffer by connecting to the memory signal RD.

4, Figure 4.12 also shows that memory places the data byte from the addressed register during
T>, and that is read by the microprocessor before the end of T.

To write into a register, the microprocessor performs similar steps as it reads from a register.
Figure 4.13 shows the Memory Write cycle. In the Write operation, the 8085 places the address
and data and asserts the 1O/M signal. After allowing sufficient time for data to become stable,
it asserts the Write (WR) signal. The IO/M and WR signals can be combined to generate the
MEMW control signal that enables the input buffer of the memory chip and stores the byte in
the selected memory register.

INTERFACING THE 8155 MEMORY SECTION

Figure 4.18(a) shows the block diagram of the 8155 memory section, It has eight address lines,
one CE (Chip Enable) line, and five lines compatible with the control and status signals of the
8085: IO/M, ALE, RD, WR, and RESET. These control and status lines are not found in the
general-purpose memory devices shown in the previous section. These lines eliminate the need
for external demultiplexing of the bus AD7-AD0) and for generating separate control signals
for memory and I/O.

Figure 4,18(b) also shows the internal structure of the 8155 memory section. The memory
section includes 256 x 8 memory locations and an internal latch to demultiplex the bus lines
AD7-AD0. The memory section also requires a Chip Enable (CE) signal and the Memory Write
(MEMW) and Memory Read (MEMR) control signals, generated internally by combining the
IO/M, WR, and RD signals.

BASIC INTERFACING CONCEPTS

The approach to designing an interfacing circuit for an [/O device is determined primarily by
the instructions to be used for data transfer. An 1/O device can be interfaced with the 8085
microprocessor either as a peripheral [/O or as a memory-mapped I/O. In the peripheral I/O,
the instructions IN/OUT are used for data transfer, and the device is identified by an 8-bit
address. In the memory-mapped /O, memory-related instructions are used for data transfer, and
the device is identified by a 16-bit address. However, the basic concepts in interfacing 1/O
devices are similar in both methods.

Peripheral |/O Instructions

The 8085 microprocessor has two instructions for data transfer between the processor and the
1/O device: IN and OUT. The instruction IN (Code DB) inputs data from an input device (such
as a keyboard) into the accumulator, and the instruction OUT (Code D3) sends the contents of
the accumulator to an output device such as an LED display. These are 2-byte instructions,
with the second byte specifying the address or the port number of an IO device. For example,
the OUT instruction is described as follows,
MEMORY-MAPPED I/O

In memory-mapped I/O, the input and output devices are assigned and identified by 16-bit
addresses. To transfer data between the MPU and I/O devices, memory-related instructions
(such as LDA, STA, ete.)* and memory control signals (MEMR and MEMW) are used. The
microprocessor communicates with an I/O device as if it were one of the memory locations.
The memory-mapped I/O technique is similar in many ways to the peripheral I/O technique,
To understand the similarities, it is necessary to review how a data byte is transferred from the
8085 microprocessor to a memory location or vice versa. For example, the following
instruction will transfer the contents of the accumulator to the memory location 8000H.

Memory Machine
Address Code Mnemonics Comments
2050 32 STA 8000H ;Store contents of accumulator in mem-
-ory location 8000H
2051 00
2052 80

(Note: It is assumed here that the instruction is stored in memory locations 2050H, 51H,
and 52H.)

The STA is a three-byte instruction; the first byte is the opcode, and the second and third bytes
specify the memory address. However, the 16-bit address 8000H is entered in the reverse order;
the low-order byte 00 is stored in location 2051, followed by the high-order address 80H (the
reason for the reversed order will be explained in Section 5.6). In this example, if an output
device, instead of a memory register, is connected al this address, the accumulator contents will
be transferred to the output device, This is called the memory-mapped I/O technique,

On the other hand, the instruction LDA (Load Accumulator Direct) transfers the data from a
memory location to the accumulator. The instruction LDA is a 3-byte instruction; the second
and third bytes specify the memory location. In the memory-mapped I/O technique, an input
device (keyboard) is connected instead of a memory, The input device will have the 16-bit
address specified by the LDA instruction. When the microprocessor executes the LDA
instruction, the accumulator receives data from the input device rather than from a memory
location. To use memory-related instructions for data transfer, the control signals Memory
Read (MEMR) and Memory Write (MEMW) should be connected to I/O devices instead of
IOR and IOW signals, and the 16-bit address bus (A15-A0) should be decoded.

You might also like