3CS Microprocessor Notes
3CS Microprocessor Notes
Unit I
8085-Instruction Cycle
Unit II
Unit III
Unit IV
Unit V
Text Book:
Reference Book:
INTRODUCTION
Introduction:
The Term LSI refers to IC’s containing components usually transistors in the range of 1000–
10,000. A VLSI chip contains more than 10,000 transistors. A CPU built into a single LSI or VLSI
chip is called a Microprocessor. A microprocessor combined with memory and input/output devices
forms a microcomputer.
A digital computer understands information’s composed of only zeros and ones. It uses binary
numbers for its operation. There are only two digits 0 and 1 in the binary number system. therefore,
instructions and data fed to the CPU of a digital computer must be in terms of 0s and 1s. a binary digit
is known as a bit. The word ‘bit’ is the short form of the term ‘binary bit’. A group of 8 bit is called a
byte.
The first microprocessor was introduced in 1971 by Intel corporation, U.S.A. it was a 4-bit
microprocessor, in Intel 4004. in 1972 Intel introduced the 1 st 8-bit microprocessor, the Intel 8008. the
Intel 4004 and 8008 both used PMOS technology. In 1973 a more powerful and faster 8-bit
A 4-bit microprocessor means that the processor makes processing of 4 bits in parallel at a
time. If there are data containing more than 4 bits, the microprocessor will take up 4 bits of the data for
processing first, then the next group of 4 bits and so on. Similarly an 8-bit microprocessor handles 8
Example of 8-bit microprocessors are Intel 8085, Motorola’s MC6809,Zilog’s Z80 and Z800.
16-bit microprocessor are Intel’s 8086, 80816 and 80286, Motorola’s MC 68000, Zilog’s Z8000 series.
32 bit microprocessor are Intel’s 80386, 80486, Motorola’s 68030 and 68040.
The number of bits that a digital computer can process in parallel at a time is called its word
length. It is a measure of computing power of a computer. A 4-bit microcomputer has a word length of
4 bits. Microcomputer have word lengths of 4 – 32 bits whereas large computer 32-64 bits.
4-bit microprocessors are used for simple applications such as domestic appliance control,
calculators, video games, toys etc. 16-bit microprocessor have more powerful instructions set than that
of 8-bit microprocessor. They use VLSI technology. They can directly address memory in the range of
1M bytes to 16M bytes. 16-bit microprocessor are designed to work in multiprocessor environment
and use high-level language. Some 16-bit microprocessors, contain additional circuits besides CPU.
memory. Intel 80486 is the latest 32-bit advanced microprocessor. It is more powerful than 80386. it
contain a CPU, a floating point coprocessor, memory management unit and 8 KB cache memory on
GB memory. It contain a CPU, memory management unit, a 256 bytes of instruction cache and a 256
bytes of data cache. Motorola 68040 is more powerful 32-bit microprocessor. It contains a CPU,
memory management unit, a powerful floating point coprocessor. Motorola MC88100 is a 32-bit RISC
processor.
in 1623 but it was not popular. In 1642 Blaise Pascal made a mechanical adding machine. It performed
addition and subtraction automatically. In 1671 Gottfried Leibriz made a machine which was able to
perform multiplication and division automatically. These machines performed computation in single
The first electronic digital computer ENIAC was built in 1946. it used electronic valves as its
main components. The digital computers using electronic valves are known as first generation
computers. Examples of first generation computers are: ADVAC, IBM 701, IBM 704, IBM 709,
UNIVAC I etc.
The Second Generation computers (1955-1964) used transistors instead of vacuum tubes as
CPU components and ferrite cores of main memory. Examples of second generation computers are:
IBM 1620, IBM 7090, IBM 7094, CDC 1604, PDP 5 etc. Second generation computers used high-
Third generation computers used IC’s instead of transistors. ICs were also used for main
Examples of third generation computers are: IBM 370, CDC 7600, PDP-11 series, Cyber-175, STAR
100, etc.
Fourth generation computers used Microprocessor. Computers available today are fourth
generation computers. Example are CRAY Y-MPC(1992), CRAY Y-MP(1988), CRAY 2(1985), IBM
ES(1900), IBM 3090/600(1988), VAX 9000/420, VAX 8842 (1988), IBM AS/400/B60 (1988), IBM
PS/2/50 (1987), IBM PS/2 model 80, WIPRO LANDMARK 860, HCL-Magnum 040 series, HP 9000,
Fifth generation computers are in research and development stage. U.S.A. and Japan have
projects to develop fifth generation computers. These computers will use ULSI chips which contain
Microcomputer containing CPU, RAM, ROM and I/O ports on a single chip have been
Examples of single chip microcomputers are the Intel 8048 and 8051 series, Motorola’s M6801
Most of the microcomputers are 8-bit microcomputers. The Intel 8051 is the latest single chip
8-bit microcomputer which has very powerful instruction set and operates with 12 MHz clock.
Intel 8096 series of microcomputers are 16-bit single chip microcomputers. The 8096 contains
a 16-bit CPU, 8K ROM, 232 bytes RAM, Timer/counter, 10-bit A/D converter, I/O ports etc.
main components are: CPU (central Processing Unit), memory, input device and output device as
shown in figure 1.2. The physical and circuitry of a computer are called Hardware. A physical device
written for a particular computer known as Software for that computer. The input and output devices
are known as peripherals. Peripheral includes memory, ROM, PROM, EPROM EEPROM’s are
known as firmware.
a) CPU: The Central processing Unit(CPU) fetches from the memory and performs specified tasks. It
store results in the memory or sends results to the output device. The CPU controls and communicate s
such as addition and subtraction; and logical operations such as AND, OR and
EXCLUSIVE-OR.
ii. Timing & Control Unit: This unit controls the entire operation of a computer. It act as a
brain. it also controls all other devices connected to CPU. It generates timing signals
iii. Accumulator & General purpose Register: the accumulator is a register which contains one
of the operands and store results of most arithmetic & logic operations.
iv. General purpose register are used for temporary storage of data and intermediate results
b) Microprocessor: The LSI and VLSI technology it became possible to build the entire CPU on a
single chip IC. A CPU built into a single LSI/VLSI chip is called a microprocessor. The main section
of a microprocessor are: ALU, timing & control unit, accumulator, general purpose and special
purpose register.
c) Memory: The memory is a storage device. It store program, data, results etc.
d) Input device: The computer receives data and instructions through input devices. An input devices
converts the instructions, input data and signal into proper binary form suitable for a digital computer.
e) Output device: The computer sends results to output devices. An output device may store, print,
display or send electrical signal to control. The example of simple output devices are printers, CRT,
1.5 Memory:
The function of memories is to store program, data and results. There are two kinds of
memories: semiconductor memories and magnetic memories. Semiconductor memories are faster,
smaller, lighter and consume less power. Semiconductor memories are used as the main memory of a
computer. Magnetic memories are slow but they are cheaper than semiconductor memories. Magnetic
memories are used as the secondary memories of a computer for bulk of data and information’s.
a) Semiconductor memories: there are two important types of semiconductor memories: RAM
(Random Access Memory) and ROM (Read Only Memory). There are various types of RAM
and ROM.
b) RAM: The read and write memory of a computer is popularly known as RAM. It is also called
R/W memory. Information can be read from and written into it during normal operation. It has
random access property. The abbreviation RAM stands for random access memory. In a
random access memory any memory location can be accessed in a random fashion without
c) iRAM: iRAM stands for integrated RAM. iRAM integrates dynamic RAM and it’s control and
d) ROM: A ROM is a read only memory. It is non-volatile. It is used for permanent storage. It
has also a random access property. It contain assembler, compiler, monitor, debugging program
or any other permanent program. ROMs are widely used for function tables (sine, cosine,
e) PROM: A PROM is a programmable ROM. The content of a PROM is decided by the user.
The user can write permanent program in a PROM. A special equipment for PROM
f) EPROM: An EPROM is an erasable PROM. The contents are erased by exposing EPROM to
high intensity intensity short wave ultraviolet light for 10 to 20 minutes. EPROMs are cheap,
g) EEPROM: EEPROMs are electrically erasable PROM, they need not be removed from a
microcomputer board erasing. The change in contents is made in milliseconds which is much
less than the erasing time of an EPROM. A single byte of data or the entire device can be
h) Magnetic Memories: Magnetic memories are slower, they are used in computer system for
bulk storage. The important memories are: magnetic tape, floppy disk, hard disk and magnetic
bubble type memories. All of these memories except magnetic bubble type memory have
rotating mechanical parts. Magnetic tapes, floppy disks and hard disks are used as mass
storage(bulk memory). Mass storage devices are used to store information at a lower cost per
bit.
i) Magnetic Tape Storage: Magnetic tapes are used for bulk storage. Tapes are cheaper than
other magnetic storage devices. The tape is usually made of Mylar with a thin coating of
magnetic iron oxide. It’s width varies from ¼ inch to ½ inch. Narrow tapes contain one or more
tracks and data words are stored in serial from on a single track. Large commercial recorders
On wide tapes data words are stored in parallel form on parallel tracks. Tape is a surface
device. It is slow being serial access type memory. Sometime locating a file takes several
seconds. Once a file is located some parallel track recorders can read about 2,50,000 character
per second. Magnetic tapes are used as backup storage. Floppy disks are used as backup
storage. The difficulty with floppy disk is that a large number of floppy disks is required.
j) Floppy Disks: Floppy disk is Mylar disk coated with magnetic material iron oxide. 0 and 1 are
stored in the magnetic material in the form of magnetic directions. Floppy disks have shorter
access time than magnetic tapes. Disk is rotated at a constant speed of 360 r.p.m. the floppy
disk surface is divided into a number of tracks. Each tracks is further divided into a number of
sectors. There is a hole at the centre for driving the disk. A write protect notch is provided to
protect stored information. Each track and sector has a binary address using which the
processor can read/write information. The transfer of data from or to a track is done in serial
k) Hard Disks: A hard disk uses a rigid aluminium base with a thin coating magnetic material.
The disk is enclosed in a sealed container. To increase the storage capacity per drive several
disks can be attached to a common spindle to form a disk pack. An individual read/write head
for each disk is used. Standard hard disk sizes are:3 1/2 and 51/4 inch diameter. The speed of a
hard disk is in range of 1000 to 3600 r.p.m. the disk drive for a hard disk is known as
Winchester drive.
l) Optical Disk: Optical disks are used to store huge amount of data for computers. 1 Gbytes of
data can be stored on one side of a 12 inch optical disk, this storing capacity corresponds to
about 400,000 pages of text. There are three types of optical disks: read only, write once/read,
and read/write.
1.6 Buses:
Various input/output devices and memories are connected to the CPU by a group of lines called
a Bus. There are three types of buses: Address bus, Data bus and Control bus. The bus architecture of a
microcomputer has been shown in [Link] Address bus carries the address of a memory location
or I/O device that a CPU has to access. The address bus is unidirectional. Data and control buses are
bidirectional. A Data bus is used for the transfer of data between the processor and memory or I/O
devices. The Control bus is used to carry control signals between CPU and various devices connected
to it.
The address bus of an 8-bit microprocessor is usually 16-bit wide. A 16-bit wide address bus
The memory addressing capacity of a CPU depends on the width of it’s address bus. If a CPU
has n-bit wide address bus, it can directly address 2n memory locations. For example, a CPU having a
16-bit wide address bus can directly address up to 2 16=64K memory locations. One memory location
store 1 byte of information. Therefore, a CPU having a 16-bit wide address can directly address 64K
bytes of memory.
Suppose, There are only 2 lines in an address bus. The only possible addresses for memory
locations are: 00,01,10,11. these are equal to 4=2 2. if an address bus has 3 lines, it can address memory
i) Microcomputer: Low-cost small digital computers are known as microcomputers. The two word
length of a microcomputer may be 8-bit, 16-bit or 32-bit. Microcomputers are widely used in industrial
manipulation work are called personal computer. Personal computer are classified into PC, PC/XT,
PC/AT and super AT. All categories of personal computers contain a CPU, memory(RAM and ROM),
secondary memory (hard disk/floppy disk), CRT display, and a keyboard, printer is optional.
PC (Personal computer). These are simplest and cheapest personal computers. They are use
Intel 8088 CPU, 640 KB memory, floppy disk drives, CRT display and keyboard. The operating
system is MS-DOS. PCs do not contain hard disks. They contain two floppy disk drives, the capacity
hard disks. It’s ROM capacity is of 8 KB, expandable up to 48 KB. Clock speed is 10 MHZ. the hard
disk capacity is usually 20 MB/ 40 MB. Operating system is MS-DOS. The CPU 8088 can directly
address up to 1 MB memory.
PC/AT (Personal Computer Advanced Technology). It’s CPU is more powerful, Intel
80286. it can directly address up to 16 MB memory. It is a 16-bit CPU. It data bit is 1-bit wide. It has
been designed for multiuser and multitasking environment. It can support 4 terminals. It’s clock is
12MHZ. the memory capacity of PC/AT is 640 KB or 1 MB expandable to 9 MB. The hard disk
capacity is 20MB/40MB/80MB.
Super AT. Super ATs use 32-bit CPU Intel 80386 or Intel 80486. their clock speed may be 20
MHZ, 25 MHZ. the memory capacity is 2 MB expandable to 16 MB. The hard disk capacity is 80
Video monitor(display) units have 14 inch screen size. The display may be MGA/CGA, CGA
or VGA high resolution type. MGA is monochrome(single color) graphics adaptor, CGA is color
Home Computers: These are very small computers, they are used in home appliances, simple
ii) Minicomputers: Minicomputers are more powerful, faster and costlier than microcomputer. Their
word length is 32-bit. Motorola 68030 and Intel 80486 are used as CPU. Their processing speed may
lie in the range of 10-30 MIPs. Their RAM capacity lies in the range of 8MB-96MB. The hard
capacity is 380 MB- 3 GB. They are used in industry, government organizations, universities, research
organizations etc.
Examples of minicomputers are: IBM AS/400/B60; VAX 8842, WIPRO S-68030, Motorola
iii) Mainframe Computers(or Large Computers): Mainframe computers are more powerful, faster
and costlier than minicomputers. Their processing speed lies in the range of 30 – 100 MIPS. Their
word length may be 48, 60 or 64 bit. Their RAM capacity lies in the range of 64 MB - 256 MB, hard
disk capacity 1000 MB – 10 GB. Mainframe computers are used in complex computation, to process
large amount of data. They are used in large industries, large business and government organizations,
research organizations, banks, airlines, places where large database is required and so on. Hundreds of
Example of mainframe computers are : IBM enterprise System/900 series, HP 9000 Model
870S/400, HP 9000 model 870S/300, IBM 4300 series, IBM 308X series, IBM 3090 series etc.
iv) Supercomputers: Supercomputers are more powerful, much faster and costlier than mainframe
computer. Their word length may be 64-bit or 96-bit, memory capacity 256 MB or more, hard disk
capacity 1000 MB or more, processing speed 400 MIPS – 10,000 MIPS. Supercomputers are used for
solving very sophisticated problems. They are used for weather forecasting, aerodynamics,
seismology, atomic, nuclear, plasma physics, for weapons research and development, sending rockets
Examples of supercomputers are : CRAY X-MP/14, X-MP/24 and X-MP/48, CRAY Y-MP.
Intel 8085 is an 8-bit microprocessor. It is a 40 pin I.C. package fabricated on a single LSI chip.
The Intel 8085 uses a single +5Vd.c. supply for it’s operation. Its clock speed is about 3 MHz. it has 80
basic instructions and 246 opcodes. Fig 3.1 shows the block diagram of Intel 8085. It consists of three
main sections, an Arithmetic and Logic unit, a Timing and Control unit and several registers.
ALU: The arithmetic and logic unit, ALU, perform the following arithmetic and logical operations.
i. Addition
ii. Subtraction
iv. Logical OR
v. Logical EXCLUSIVE OR
x. Clear
Timing & Control Unit: The Timing and control unit is a section of CPU. It generates timing and
control signals which are necessary for the execution of instructions. It control data flow between CPU
and peripherals. It control the entire operations of the microprocessor and peripheral connected to it.
Control unit of the CPU acts as the brain of the computer system.
Registers: Fig. 3.1 shows the various registers of Intel 8085. registers are used by the microprocessor
for temporary storage and manipulation of data and instructions. In a large computer the number of
registers is more. In a small computer the number of registers is small due to limited size of the chip.
ii. Six 8-bit general purpose registers. These are B,C,D,E,H and L.
v. Instruction register
Fig 3.1 shows the block diagram of Intel 8085. the program counter PC, contains the address of the
next instruction. The CPU fetches an instruction from the memory, execute it and increments the
content of the program counter. Next instruction cycle it will fetch the next instruction of the program.
The stack pointer SP, holds the address of the stacktop. The stack is a sequence of memory
locations defined by the programmer. The stack is used to save the content of a register during the
execution of a program. The last memory location of the occupied portion of the stack is called
stacktop.
There are six 8-bit registers which are used for general purpose as desired by the programmer.
These 8-bit registers are: A,B,C,D,E,H and L. to handle 16-bit data two 8-bit registers can be
combined. The combination of two 8-bit register is called register pair. The register pair of Intel 8085
are B-C, D-E and H-L. the H-L pair is used to address memories. The register A is accumulator in Intel
8080/8085. this is used during the execution of a program for temporary storage. The final result of an
There is a set of flip-flops which act as flags. Each of these flip-flops holds 1-bit flag that
indicates certain condition which arises during arithmetic and logic operations. The following status
Carry (CS): The carry status flag holds carry out of the most significant bit resulting from the
execution of the an arithmetic operation. If there is a carry from addition or a borrow from the
Zero (Z): The Zero status flag is set to 1 if the result of the arithmetic or logical operation is zero. For
Sign (S): The sign status flag is set to 1 if the most significant bit of the result of an arithmetic or
Parity (P): The parity status flag is set to 1 when the result of the operation contain even number of
Auxiliary carry (AC): The auxiliary carry status flag holds the carry out of bit 3 to 4 resulting from
Fig. 3.2 (a) shows the position of various status flags of Intel 8085.
Fig. 3.2 (b) shows the status flags for ADD operation.
Example, the instruction ADD B. the execution of the instruction ADD B will add the content of the
register B to the content of the accumulator. The contents of the accumulator and register B are CB
and E9 respectively. Now CB and E9 are added and the result is 01, B4. As the accumulator is an 8-bit
register B4 remains in the accumulator and there is a carry. The various status flags are shown in fig.
3.2 (b).
PSW: In fig. 3.2 (a), five bits indicate the five status flags and three bits are undefined. The
Data & Address Bus: The Intel 8085 is an 8-bit microprocessor. It data bus is 8-bit wide, 8 bit of data
can be transmitted in parallel form or to the microprocessor. The Intel 8085 requires a 16-bit wide
address but as the memory address are of 16 bits. The 8 most significant bits of the address are
transmitted by the address bus, A-bus (pins A8-A15). The 8 least significant bits of the address are
transmitted by address/data bus, AD-bus (pins AD 0 – AD7). The address/data bus transmits data and
address at different moments. At a particular moment it transmit either data or address. Thus the AD-
First of all 16-bit memory address is transmitted by the microprocessor; the 8MSBs of the
address on the A-bus and 8 LSBs of the address on AD-bus. Thus, the effective width of the address
bus becomes 16-bit wide. Each memory location contains 1 byte of data.
Pin Configuration:
Fig 3.3 shows the schematic diagram of Intel 8085. The description of various pins are as
follows:
A8-A15 (output): These are address bus and are used for the most significant bits of the memory
AD0-AD7 (input/output): These are time multiplexed address/data bus i.e. they serve dual purpose.
They are used for the least significant 8 bits of the memory address or I/O address during the first
clock cycle of a machine cycle. Again they are used for data during second and third clock cycles.
ALE (output): It is an address latch enable signal. It goes high during first clock cycle of a machine
cycle and enables the lower 8 bits of the address to be latched either into the memory or external latch.
IO/M (output): It is a status signal which distinguishes whether the address is for memory or I/O.
when it goes high the address on the address bus is for I/O devices. When it goes low the address on
S0, S1 (output): These are status signals sent by the microprocessor to distinguish the various types of
RD (output): It is a signal to control READ operation. When it goes low the selected memory or I/O
device is read.
WR (output): It is a signal to control WRITE operation. When it goes low the data on the data bus is
READY (input): It is used by the microprocessor to sense whether a peripheral is ready to transfer
data or not. If READY is high the peripheral is ready. If it is low the microprocessor waits till it goes
high.
HOLD (input): It indicates that another device is requesting the use of the address and data bus.
Having received a HOLD request the microprocessor relinquishes the use of the buses as soon as the
current machine cycle is completed. The processor regains the bus after the removal of the HOLD
signal. When a HOLD is acknowledged, address bus, data bus, RD, WR, and IO/M are tri-stated.
HLDA (output): It is a signal for acknowledgement. It indicates that the HOLD request has been
received. After the removal of the HOLD request the HLDA goes low. The CPU takes over the buses
INTR (input): It is an interrupt request signal. Among interrupts it has the lowest priority. When it
goes high the program counter does not increment it’s content. After completing the instruction at hand
it goes to the CALL instruction. The microprocessor acknowledges the interrupt signal and issues an
INTA signal. The INTR is enabled or disabled by software. An interrupt is used by I/O devices to
INTA (output): It is an interrupt acknowledgement sent by the microprocessor after INTR is received.
RST 5.5,6.5,7.5 & TRAP (input): These are interrupts. When an interrupt is recognized the next
TRAP 0024
RST 7.5, RST 6.5,RST 5.5 are the restart interrupts. They cause an internal restart to be automatically
inserted. Each of them programmable mask. The TRAP has the highest priority among Interrupts. The
RST 7.5
RST 6.5
RST 5.5
RESET IN (input): It resets the program counter to zero. It also resets interrupt enable and HLDA
flip-flops. It does not affect nay other flag or register except the instruction register.
X1,X2 (input): These are terminals to be connected to an external crystal oscillator which drives an
internal circuitry of the microprocessor to produce a suitable clock for the operation of microprocessor.
CLK(output): It is a clock output for user, which can be used for other digital ICs. Its frequency is
SID (input): It is data for serial input. The data on this line is loaded into the 7 th bit of the accumulator
SOD (output): It is a data line for serial output. The 7th bit of the accumulator is outputted on SOD
A computer receives data from user, processes data and sends the result back to the user. An
instruction is a command given to the computer to perform a specified operation on given data.
MOV M,r : The content of register r is moved to the memory location whose address is in H-L pair.
Example, MOV M, A will transfer the content of accumulator to the memory location specified by H-
L pair.
MVI r, data : The given just after an instruction are moved to the register r.
LXI rp, data 16-bit : 16-bit immediate data are moved to the register pair rp.
LDA addr : The content of memory location whose address is specified within the instruction itself is
Example, LDA 2400H moves the content of the memory location 2400H to the accumulator.
STA addr : The content of accumulator is moved to the memory location whose address is specified
Example, STA 2500H moves the content of the accumulator to memory location 2500H.
Example, ADD B adds the content of B to the content of the accumulator and places the sum in the
accumulator.
SUB r : The content of the register r is subtracted from the content of accumulator and the result is
Example, SUB C subtract the content of register C from the content of the accumulator and places
RAL : The content of the accumulator is rotated left one bit through carry.
IN Port-address : This instruction transfer data from input devices. The data available at the input
OUT Port-address: This instruction transfer data from processor to the output device. The content of
Each instruction contains two parts: operation code (opcode) and operand. The first part of an
instruction which specifies the task to be performed by the computer is called opcode. The second part
The machined code of all instructions are not of the same length, according to the word size the
Intel 8085 instructions are classified into the following three types.
a. MOV A, B: Move the content of register B to register A. 78H is the opcode for MOV
A, B. the opcode 78H written in the binary form as 01111000. the 1 st two bits, i.e. 01 are
for MOV operation; next three bits 111 are the binary code for register A and last three bits
b. ADD B: Add the content of register B to the content of the accumulator.80H is the opcode
for the instruction ADD B. the opcode 80H in the binary form is 10000000. the first five
bits, i.e, 10000 specify the operation to be performed i.e. ADD operation. The last three bits
c. RAL : Rotate the content of the accumulator left by one bit. The opcode for the RAL is
17H.
Two word or 2-byte instruction: In a two byte instruction the 1st byte of the instruction is it’s opcode
The 1st byte 06 is opcode for MVI B and 2nd byte 05 is the data which is to be moved to
register B.
Three word or 3-byte instruction: In a three byte instruction the 1st byte of the instruction is its
opcode and the 2nd and 3rd bytes are either 16-bit data or 16-bit address.
The 1st byte 21 is the opcode for the instruction LXI H. the 2 nd byte 00 is 8 LSB’s of the data
(2400H), which is loaded into register L. the 3 rd byte 24 is 8 MSB’s of the data (2400H), which is
b. LDA 2500 H : the content of the memory location 2500H into accumulator.
The 1st byte 3A is opcode for the instruction LDA. The 2 nd byte 00 is 8 LSB’s of the address
of the memory location 2500H. the 3 rd byte 25 is 8 MSB’s of the address of the memory location
2500H. the data is the content of the memory location 2500H. the data is to be loaded into the
accumulator.
data. To perform a particular task a programmer writes a sequence of instructions, called a program. A
program an data are stored in memory. The CPU fetches one instruction from memory at a time and
execute it. It execute all the instructions of a program one by one to produce the final result.
CPU carries out to fetch an instruction and necessary data from the memory, and execute it
constitute an instruction cycle. An instruction cycle consists of a fetch cycle and execute cycle. In
fetch cycle a CPU fetches opcode from the memory. The carried data from memory and to perform the
IC = FC + EC
Fetch operation:
The 1st byte of an instruction is its opcode. An instruction may be more than one byte long. The
other bytes are data or operand. The program counter (PC) keeps the memory address of next
instruction to be executed. The entire operation of fetching an opcode tasks three clock cycles. The
clock cycle for which the CPU waits is called wait cycle.
Execute Operation:
The opcode fetched from the memory goes to the data register, DR and then to instruction
register, IR. The CPU has to perform some read operation to get the desired data. After receiving the
data it performs execute operation. A read cycle is similar to fetch cycle. In write cycle data are sent
from the CPU to the memory or an output device. Fig. 3.4,3.5 shows an instruction and fetch cycle
respectively.
The necessary steps carried out to perform the operation of accessing either memory or I/O
device, constitute a machine cycle. The steps carried out to perform fetch, a read or a write operation
In a machine cycle one basic operation such as opcode fetch, memory read, memory write I/O
read and I/O write is performed. An instruction cycle consist of several machine cycle. two-byte and
Fig.3.6 shows instruction cycle for MVI r, data. It has two machine cycles: one for fetching
opcode and the other for reading data from the memory and execution. One subdivision of an
A computer receives instructions and data both in binary form. A group of 8 bit is called a byte.
Data and instructions for computers are specified in the byte form. The word length of a computer is
the number of bits it handles at a time. Two kinds of word, namely instruction word (instruction code
or opcode) and data word are processed during an instruction cycle. At the beginning of a fetch cycle
the content of the program counter is transferred to a special register known as memory address
register, MAR or address register, AR; the content of MAR is transferred to the memory through the
address bus. The decoder circuitry in the memory is activated. The opcode first comes in memory data
The execution of an instruction requires the flow of data word in the most of the instructions.
The flow of data word is shown in fig.3.8. a data word is received either from the memory or input
device. The data word flows to the processor through the data bus and is placed in the accumulator or
any other general purpose register depending upon the instruction. After the execution of instruction
the data in a placed in a register or memory location. After the execution of a program the result(data)
The necessary steps which are carried out in a machine cycle can be represented graphically,
such a graphical represented is called timing diagram. The timing diagram for opcode fetch, memory
read, memory write I/O read and I/O write will be discussed below.
In a fetch cycle the microprocessor fetches the opcode of an instruction from the memory. Fig. 3.9
shows the timing diagram for an opcode fetch cycle. T 1, T2, T3 and T4 are consecutive four clock
cycles. The microprocessor issues a low IO/M’ signal to indicate that it wants to make communication
with the memory. Again the microprocessor sends out high S 0 and S1 signals to indicate that it is going
During the first clock cycle, T 1, the microprocessor sends out the address of the memory location
where the opcode is available. The 16-bit memory are sent through the address bus A and
address/data bus AD. The 8 MSBs of the memory address are sent over the A bus, and 8 LSBs of the
memory address over AD bus. Since the AD bus is needed to transfer data and subsequent clock
cycles, it is used in time-multiplexed mode. Therefore, it has to be made available to carry data during
T2 and T3. To accomplish this the microprocessor sends an address latch enable signal ALE to latch
the 8 LSBs of the memory address either in the memory or an external latch so that the complete 16-bit
16-bit memory address is needed by the memory to obtain the opcode from the given memory
address. During T2, AD bus become ready to carry data. In T2 the microprocessor makes RD’ low.
Now memory gets the opcode from the specified memory location and places it on the data bus.
During T3 the opcode is placed in the instruction register, IR which is within the microprocessor. The
memory is disabled when RD’ goes high during T 3. the fetch cycle is completed T3. The opcode is
decoded in T4. The microprocessor examines READY signal in T 2. If it is high, the microprocessor
enters into T3 state. If it is low, the microprocessor inserts a wait state in between T2 and T3.
If an instruction is one byte long, only one machine cycle as shown in Fig.3.9 is required toe fetch
and execute the instruction. Examples of one long instructions are MOV, SUB, ADD, RAL, etc. As
the operands are in the general purpose registers. The decoding of the operation code and its execution
takes only one clock cycle, T4. if an instruction is two or three bytes long, it requires more machine
cycles. The first machine cycle M 1 is for fetching the opcode from the memory. Subsequent machine
cycle M2, M3 etc. are required either to read data or address from the memory or I/O device or to write
data into the memory or I/O device. Fig M1 shows fetch cycle, and M2 a data read cycle.
Memory Read:
In a memory read cycle the microprocessor reads cycle the microprocessor reads the content of a
memory location. The content is then placed either in the accumulator or any other register of the
MVI A,05
3E, 05
This instruction requires two machine cycle, M 1 and M2. The first machine cycle M1 is to fetch the
operation code 3E from the memory. The timing diagram for opcode fetch operation has already been
shown in Fig.3.9. The second machine cycle M2 is for reading the data (05) from the memory as
shown in Fig.3.11. It is a memory read cycle. IO/M’ goes low indicating that the address is for
memory. S1 and S0 are set to 1 and 0 respectively for the read operation. See table 3.1. on the address
lines A8-A15, the 8 MSBs of the memory address of the data(05) are sent. During T 1., 8 LSBs of the
memory address of the data sent on AD 0-AD7. during T2, 8 LSB of the address is latched and AD 0-
AD7 are made free for data transmission. RD’ goes low in T2 to enable the memory for read operation.
I/O Read:
In an I/O read cycle the microprocessor reads the data available at an input port or input device.
The data is placed in accumulator. An I/O read cycle is similar to memory read cycle. The only
difference between a memory read cycle and I/O ready is that that signal IO/M’ goes high in case of
I/O read. It indicates that the address on the A-bus is for an output device. In timing diagram all other
Memory Write:
In a memory write cycle the CPU sends data from the accumulator or any other register to the
memory. The timing diagram for a memory write cycle is shown in fig 3.12. the status signals S 0 and
S1 are 1 and 0 respectively for write operation. WR’ goes low in T 2 indicating that the write operation
is to be performed. During T2 the AD bus is not disabled as it is done in case of memory or I/O read
operation. But the data to be sent out to the memory is placed on the AD-bus. WR’ goes high in T 3.
I/O Write:
In an I/O write cycle the CPU sends data to an I/O port or I/O device from the accumulator.
An I/O write cycle is similar to a memory write cycle. In case of I/O write cycle IO/M’ goes high
indicating that the address sent out by the CPU is for I/O device or I/O port. The address of I/O port or
device is duplicated on both A and AD buses. It require three machine cycles. The first machine cycle
is for opcode fetch operation, the second machine cycle is a memory read cycle, third machine cycle is
data. The instruction set of a microprocessor is the collection of the instructions that the
microprocessor is designed to execute. The instructions have been classified into the following groups:
ii. Branch Control Group iv. I/O and Machine Control Group
Instruction which are used to transfer data from one register to another register, from memory
to register or register to memory, examples are MOV MVI, KXI, LDA, STA etc. when an instruction
of data transfer group is executed, data is transferred from source to destination without altering the
For example, MOV A, B is executed the content of register B is copied into the register A, the
The instruction of this group perform arithmetic operation such as addition, subtraction,
increment or decrement of the content of a register or memory. Examples are: ADD, SUB, INR, DAD
etc.
The instructions of this group perform logical operation such as AND, OR; compare, rotate etc.
This group includes the instructions for conditional and unconditional jump, subroutine call
and return, and restart. Examples are: JMP, JC, JZ, CALL, CZ, RST etc.
This group includes the instructions for input/output ports, stack and machine control.
Intel 8085 is an 8-bit microprocessor, it handles 8-bit data at a time. One byte consist of 8-bits.
A memory location for Intel 8085 microprocessor is designed to accommodate 8-bit data. If 16-bit data
are to be stored, they are stored in consecutive memory locations. The address of a memory location is
The machined code of all instructions are not of the same length, according to the word size the
Intel 8085 instructions are classified into the following three types.
d. MOV A, B: Move the content of register B to register A. 78H is the opcode for MOV
A, B. the opcode 78H written in the binary form as 01111000. the 1 st two bits, i.e. 01 are
for MOV operation; next three bits 111 are the binary code for register A and last three bits
e. ADD B: Add the content of register B to the content of the accumulator.80H is the opcode
for the instruction ADD B. the opcode 80H in the binary form is 10000000. the first five
bits, i.e, 10000 specify the operation to be performed i.e. ADD operation. The last three bits
f. RAL : Rotate the content of the accumulator left by one bit. The opcode for the RAL is
17H.
Two word or 2-byte instruction: In a two byte instruction the 1st byte of the instruction is it’s
The 1st byte 06 is opcode for MVI B and 2 nd byte 05 is the data which is to be
moved to register B.
Three word or 3-byte instruction: In a three byte instruction the 1st byte of the instruction is its
opcode and the 2nd and 3rd bytes are either 16-bit data or 16-bit address.
The 1st byte 21 is the opcode for the instruction LXI H. the 2 nd byte 00 is 8 LSB’s of the data
(2400H), which is loaded into register L. the 3 rd byte 24 is 8 MSB’s of the data (2400H), which is
b. LDA 2500 H : the content of the memory location 2500H into accumulator.
The 1st byte 3A is opcode for the instruction LDA. The 2 nd byte 00 is 8 LSB’s of the address
of the memory location 2500H. the 3 rd byte 25 is 8 MSB’s of the address of the memory location
2500H. the data is the content of the memory location 2500H. the data is to be loaded into the
accumulator.
Each instruction require certain data on which it has to operate. There are various techniques to
specify data for instructions. These techniques are called Addressing Modes. Intel 8085 uses the
1. Direct Addressing
2. Register Addressing
4. Immediate Addressing
5. Implicit Addressing
1. Direct Addressing:
In this mode of addressing the address of the operand (data) is given in the instruction itself.
Examples are:
STA 2400 H Store the content of the accumulator in the memory location 2400 H.
In this instruction 2400H is the memory address where data is to be stored. The 2 nd and 3rd bytes of the
instruction specify the address of the memory location. Here, the source of the data is accumulator.
2. Register Addressing:
In register addressing mode the operands are in the general purpose register. The opcode
Examples are:
The opcode for MOV A, B is 78H. the operation to be performed the opcode also specifies the register
which contain data. The opcode 78H can be written in binary form as 01111000. the first two bits, i.e.
01 are for MOV operation, next three bits 111 are the binary code for register A, and the last three bits
In this mode of addressing the address of the operand is specified by a register pair.
Examples are:
MOV A, M Move the content of the memory location, whose address is in H-L pair (i.e.,
HLT Halt.
The address of the memory resides in H-L pair and this has already been
4. Immediate Addressing:
In immediate addressing mode the operand is specified within the instruction itself.
Examples are:
LXI H, 2500 is an example of immediate addressing. 2500 is 16-bit data which is given in the
5. Implicit Addressing:
There are certain instructions which operate on the content of the accumulator. Such instruction
do not require the address of the operand. Examples are: CMA, RAL, RAR etc.
Some of Intel 8085 instructions are frequently, some occasionally and some seldom used by the
MOV, MVI, LXI , LDA, LHLD, STA, SHLD, ADD, ADC SUB, JMP, JC, JNC, JZ, JNZ, INX, DCR,
CMP etc.
MOV r1, r2. (Move data: Move the content of one register to another)
[r1] [r2].
The content of register r2 is moved to register r1. For example, the instruction MOV A, B move
the content of register B to register A. The instruction MOV B, A moves the content of register A to
register B.
[r][[H-L]].
The content of the memory location, whose address is in H-L pair, is moved to register r.
Example:
HLT Halt.
[[H-L]] [r]
The content of register r is moved to the memory location addressed by H-L pair. For example,
MOV M, C moves the content of register C to the memory location whose address is in 'H-L pair.
[r] data
the 1st byte of the instruction is its opcode. The 2nd byte of the instruction is the data which is
moved to register r. For example, the instruction MVI A, 05 moves 05 to register A. in the code form
it is written as 3E, 05. The opcode for MVI A is 3E and 05 is the data which is to be moved to register
A.
[[H-L]] data.
The data is moved to the memory location whose address is in H-L pair.
Example
HLT Halt.
In the above example the instruction LXI H, 2400H loads H-L pair with 2400H which is
address of a memory location. Then the instruction MVI M, 08 will move 08 to memory location
2400H. In the code from it is written as 36, 08. The opcode for MVI M is 36 and 08 is the data which
This instruction loads 16-bit immediate data into register pair rp. This instruction is register pair; only
high-order register is mentioned after the instruction. For example, H in instruction LXI H stands for
H-L pair. Similarly, LXI B is for B-C pair. LXI H, 2500H I 2500H into H-L pair. H with 2500H
denotes that the data 2500 is in hexadecimal. In the code form it is written as 21, 00, 25. The 1st byte
of the instruction 21 is the opcode for LXI H. 2nd byte 00 is 8 LSBs of the data and it is loaded into
register L. The 3rd byte 25 is 8 MS of the data and it is loaded into register H.
[A] [addr].
The content of the memory location, whose address is specified by the 2nd and 3rd byte of the
instruction; is loaded into the accumulator. The instruction LDA 2400H win load the content of the
memory location 2400H into the accumulator. In the code form it is written 3A, 00, 24. The 1st byte
3A is the opcode of the instruction. The 2nd byte 00 of is 8 LSBs the memory address. The 3rd byte 24
[addr] [A]
The content of the accumulator is stored in the memory location whose address is specified by
the 2nd and 3rd bytes of the instruction. STA 2000H will store the content of the accumulator in the
[L][addr], [H][adder+1].
The content of the memory location, whose address is specified by the 2nd and 3rd bytes of the
instruction, is loaded into register L. The content of the next memory location is loaded into register H.
For example, LHLD 2500H will load the content of the memory location 2500H into register L. The
The content of register L is stored in the memory location whose address is specified by the
2nd and 3rd bytes of the instruction. The content of register H is stored in the next memory location.
For example, SHLD 2500H win store the content of register L in the memory location 2500H. The
[A] [[rp]]
The content of the memory location, whose address is in the register pair rp, is loaded into the
accumulator. For example, LDAX B will load the content of the memory location, whose address is in
B-C pair, into the accumulator. This instruction is used only for B-C and D-E register pairs.
[[rp]][A]
The content of the accumulator is stored in the memory location whose address is in the
register pair rp. For example, ST AX D will store the content of the accumulator in the memory
location whose address is in D-E pair. This instruction is true only for register B-C and D-E.
[H-L] [D-E].
The content of H-L pair are exchanged with contents of D-E pair.
[A][A]+[r].
The content of register r is added to the content of accumulator, and the sum is placed in the
accumulator.
[A][A]+[[H-L]].
The content of the memory location is addressed by H-L pair is added to the content of the
[A][A]+[r]+[CS]
The content of the register r and carry status are added to the content of the accumulator. The
[A][A]+[[H-L]]+[CS]
The content of the memory location addressed by H-L pair and carry status are added to the
[A][A]+data
The immediate data is added to the content of the accumulator. The 1 st byte of the instruction is
opcode. The 2nd byte of the instruction is data, and it is added to the content of the accumulator. The
[A][A] +data+[CS]
The 2nd byte of instruction (which is data) and the carry status are added to the content of the
[H-L] [H-L]+[rp]
The content of register pair rp are added to the contents of H-L pair and the result is placed in
[A] [A]-[r]
The content of register r is subtracted from the content of the accumulator, and the result is
[A] [A]-[[H-L]]
The content of memory location addressed by the H-L pair is subtracted from the content of the
[A] [A]-[r]-[CS]
The content of register r and carry status are subtracted from the content of the accumulator,
[A] [A]-[[H-L]]-[CS]
The content of memory location addressed by the H-L pair and carry status are subtracted from
the content of the accumulator, and the result is placed in the accumulator.
[A][A]-data
The 2nd byte of instruction is data. It is subtracted from the content of the accumulator. The
[A][A]-data-[CS]
The data and carry status are subtracted from the content of accumulator. The result is placed in
the accumulator.
[r][r]+1
The content of register r is incremented by one. All flags except CS are affected.
[[H-L]][[H-L]]+1
The content of memory location addressed by H-L pair is incremented by one. Flags except CS
are affected.
[r][r]-1
The content of register r is decremented by one. All flags except CS are affected.
[[H-L]][[H-L]]-1
The content of the memory location addressed by H-L pair is decremented by one. All flags
[rp][rp]+1
[rp][rp]-1
The instruction DAA is used in the program after ADD, ADI, ACI, ADC instruction. After the
execution of ADD or ADC instruction the result is hexadecimal and it is placed in the accumulator.
The DAA instruction operates on this result and gives the final result in the decimal system. It uses
carry and auxiliary carry for decimal adjustment. 6 is added to 4 LSBs of the content of the
accumulator if their values lies between A and F or the AC flag is set to 1. similarly, 6 is also added to
4 MSBs of the content of the accumulator if their value lies in between A and F or the CS flag is set to
1.
The instructions of this group perform AND, OR, EXCLUSIVE OR operations; compare,
[A][A]^[r]
The content of register r is ANDed with the content of the accumulator, and the result is placed
in accumulator. All status flags are affected. The flag is CS is cleared. i.e. it is set to 0. auxiliary carry
flag is AC is set to 1.
[A][A]^[[H-L]]
The content of the memory location addressed by H-L pair is ANDed with the accumulator.
The result is placed in the accumulator. All flags are affected. The CS flag is set to 0 and AC to 1.
[A][A]^data
The 2nd byte of the instruction is data, and it is ANDed with the content of the accumulator. The
[A][A]V[r]
The content of register r is ORed with the content of accumulator. The result is placed in the
accumulator. All status flags are affected. Carry and auxiliary carry are cleared. i.e. the CS and AC
[A][A]V[[H-L]]
The content of the memory location addressed by H-L pair is ORed with the content of
accumulator. The result is placed in the accumulator. The CS and AC flags are set to 0.
[A][A] V data
The 2nd byte of the instruction is data and it is ORed with the content of the accumulator. The
result is placed in the accumulator. All status flags are affected. The CS and AC flags are set to 0.
[A][A]V[r]
The content of register r is EXCLUSIVE ORed with the content of the accumulator. The result
is placed in accumulator. All status flags are affected. The CS and AC flags are set to 0.
The content of the memory location addressed by H-L pair is EXCLUSIVE ORed with the
content of the accumulator. The result is placed in the accumulator. All status flags affected. The CS
The 2nd byte of the instruction is data, and it is EXCLUSIVE ORed with the content of the
accumulator. The result is placed in the accumulator. All flags are affected. The CS and AC flags are
set to O.
[A] [A’]
l's complement of the content of the accumulator is obtained, and the result is placed in the
accumulator. To obtain the l's complement of a binary number 0 is replaced by 1, and 1 by O. For
[CS] [CS’].
[CS] 1.
[A] - [r].
The content of register r is subtracted from the content of the accumulator and status flags are set
according to the result of the subtraction. But the result is discarded. The content of the accumulator
remains unchanged.
[A] - [[H-L]].
The content of the memory location addressed by H-L pair is subtracted from the content of the
accumulator, and status flags are set according to the result of the subtraction. But the result is
[A] - data.
The 2nd byte of the instruction is data, and it is subtracted from the content of accumulator. The
status flags are set according to the result of subtraction. But the result is discarded. The content of the
The content of the accumulator is rotated left by one bit. The seventh bit of the accumulator is
moved to carry bit as well as to the zero bit of the accumulator. Only CS flag is affected see
Fig. 4.1.
The content of the accumulator is rotated right by one it. The zero bit of the accumulator is
moved to the seventh bit as well as to carry bit. Only CS flag is affected. See fig. 4.2
The content of the accumulator is rotated left one bit through carry. The seventh bit of the
accumulator is moved to the carry, and the carry bit is moved to the zero bit of the accumulator. Only
The content of the accumulator is rotated right one bit through carry. The zero bit of the
accumulator is moved to the carry, and the carry bit is moved to the seventh bit of the accumulator.
The instructions of this group change the normal sequence of the program. There are two types
of branch instructions: conditional and unconditional. The conditional branch instructions transfer the
program to the specified label when certain condition is satisfied. The unconditional branch
JMP addr (label). (Unconditional jump: jump to the instruction specified by the operand)
[PC] Label
Byte 2nd and byte 3rd of the instruction give the address of the label where the program jumps. The
address of the label is the address of memory location for next instruction to be executed. The program
After the execution of a conditional jump instruction the program jumps to the instruction
specified by the address (label) if the specified condition is fulfilled. The program proceeds further in
the normal sequence if the specified condition is not fulfilled. If the condition is true and program
The program jump to the instruction specified by the address(label) if the result is zero (i.e.
zero status Z=1). Here the result after the execution of the preceding instruction is under the
consideration.
The program jump to the instruction specified by the address(label) if the result is non-zero
The program jumps to the instruction specified by the address (label) if there is a carry (i.e. the
carry status: CS = 1). Here the carry after the execution of the preceding instruction is under the
consideration.
The program jump to the instruction specified by the address(label) if there is no carry 9i.e. the
The program jumps to the instruction specified by the address (label) if the result is plus.
If the result is minus the program jumps to the instruction specified by the address (label).
If the result contains even number of 1’s, the program jump to the instruction specified by the
address (label).
If the result contains odd number of 1’s, the program jump to the instruction specified by the
address (label).
CALL addr (label): (Unconditional call: call the subroutine identified by the operand)
[[SP]-1] [PCH]
[[SP]-2] [PCL]
[SP] [SP]-2
[PC]addr (label)
CALL instruction is used to call a subroutine. Before the control is transferred to the
subroutine, the address of the next instruction of the main program is saved in the stack. The content of
the stack pointer is decremented by two to indicate the new stacktop. Then the program jumps to
[[SP]-1[PCH],[[SP]-2][PCL]
If the condition is true and program calls the specified subroutine, the execution of a conditional call
instruction take 5 machine cycles. If condition is not true only 2 machine cycles.
Conditional Return
[PCL][[SP]],[PCH][[SP]+1]
[SP][SP]+2
If the condition is true and program returns from the subroutine, the execution of a conditional return
instruction takes 3 machine cycle. If condition is not true only one machine cycle.
RST n (Restart)
[[SP]-1][PCH], [[SP]-2][PCL]
Restart is a one-word CALL instruction. The content of the program counter is saved in the
stack. The program jumps to the instruction starting a restart location. The address of the restart
location is 8 times n.
[A][Port]
The data available on the port is moved to the accumulator. After the instruction IN, the
address of the port is specified. The 2 nd byte of the instruction contains the address of the port. The
[Port] [A]
The content of accumulator is moved to the port specified by its address. After the OUT
instruction IN, the port address is specified. The 2 nd byte of the instruction contains the address of the
port.
[[SP]-1][rh],
[[SP]-2][rl],
[SP][SP]-2
[[SP]-1][A],
[SP][SP]-2
The content of the accumulator is pushed into the stack. The content of the status flags are also
pushed into the stack. The content of the register SP is decremented by 2 to indicate new stacktop.
[rl], [[SP]]
[rh], [[SP]+1]
[SP][SP]+2
The content of the register pair which was saved earlier is moved from the stack to the register
pair.
PSW [[SP]]
[A][[SP]+1]
[SP][SP]+2
The processor status word which was saved earlier during the execution of the program is
moved from the stack to PSW. The content of the accumulator which was also saved is moved from
HLT (Halt)
[H-L][SP]
EI (Enable Interrupt)
DI (Disable Interrupt)
When this instruction is executed bits 0-5 of the accumulator are used in programming the
restart interrupt masks. Bits 6-7 of the accumulator are used in making serial output on SOD line.
When this instruction is executed, the accumulator is loaded with pending interrupts, the restart
No operation is performed when this instruction is executed. The registers and flags remain
unaffected.
A computer can only do what the programmer asks to do. To perform a particular task the
programmer prepares a sequence of instruction, called a Program. A set of programs written for a
particular computer known as Software for that computer. The program is stored in RAM. The CPU
takes one instruction of the program at a time from RAM and execute it. It executes all instruction of
The instructions are coded and stored in the memory in the form of 0’s and 1’s. A program
b. Each bit has to be entered individually the entry of a program is very slow.
The writing of program in machine language is very difficult, tiresome, boring and error. To
facilitate programmers easily understandable language have been developed. Assembly language is
one of them. A programmer can easily write a program in alphanumeric symbols instead of 0s and 1s.
meaningful and easily rememberable symbols are chosen for the purpose. Examples are : ADD for
addition, SUB for subtraction, CMP for comparison. Such symbols are called Mnemonics. A program
written in mnemonics is known as Assembly language program. The writing of a program in assembly
language is much easier and faster as compared to the writing of a program in machine language.
A program which translates an assembly language program into a machine language program is
called an Assembler.
An assembler which goes through an assembly language program only once is known as one-
pass assembler. An assembler which goes through an assembly language program twice is called two-
pass assembler.
An assembly language program for the addition of two numbers placed in two consecutive
memory locations 251H and 2502H. the sum is stored in the memory location 2503H.
Example
LXI H, 2501 Get the address of the 1st number in H-L Pair
HLT Stop
Data
2501 – 49H
2502 – 56H
Result
2503 – 9F
The programmer first of all writes program in assembly language and then he fills up the
machine code corresponding to each mnemonics. This is called hand assembly. The codes are written
in hexadecimal systems. In microprocessor kit there is an arrangement for converting hexadecimal into
binary codes.
The program for the addition of two numbers in assembly language with hexadecimal codes is
given below.
LXI H, 2501 H Get the address of the 1st number in H-L Pair
HLT Stop
Data
2501 – 49H
2502 – 56H
Result
2503 – 9F
2. The assembly language is computer oriented. The programmer require to have the detailed
3. Assembly language program is not portable. i.e. the program written for one microcomputer
can not be used for any other because each microcomputer has its own assembly language.
The difficulties associated with assembly language can be overcome using High-level
languages. Instructions written in high-level languages are called statements.. In a high-level language
statements more clearly resemble English and Mathematics. Examples of high-level languages are:
FORTRAN, COBOL, BASIC, PASAL, ALGOL, PL/M etc. These languages are procedure-oriented.
The program writing in these languages is easier and faster because one statement of a high-level
language program is called a compiler. A compiler is more powerful than assembler. It check all kinds
of limits, ranges, errors etc. If a compiler runs on the computer for which it produces object codes, is
called a self-compiler or resident compiler. If it runs on a computer other than that for which it
codes, statement wise. It does not translate the entire program at a time. It takes up one statement of a
IBM. It is an ideal language for scientific and engineering computation as it contains functions for
complex mathematical operations. There are several versions of this Language. Earlier, FORTRAN IV
was very popular. In 1977 the American National Standards Institute (ANSI) published a standard for
FORTRAN with an idea that all manufacturers should same form of the language. This standard form
of the language is FORTRAN 77. This' most popular and Widely used language for scientific and
COBOL. This abbreviation stands for Common Business Oriented Language. It was
introduced in 1960 by U.S. industry/government committee. It is a widely used language for large
business application/data processing such as handling of ledgers, accounts and payroll files.
PASCAL. It is a high-level. language named in the honour of the inventor of the first
mechanical calculator, Blaise Pascal (a French mathematician). The language was developed Nicklaus
Wirth in Switzerland in the early 1970s. It is suitable for both scientific and business applications, and
suitable for a smaller system. Program design and debugging is simpler. Program compiled from
PASCAL runs several times faster than the same program compiled from BASIC or FORTRAN.
scientific and engineering computation. It is not as powerful as FORTRAN. It is simple and easy
handling numerical computation encountered in science and engineering. It was introduced in 1960 by
international committee. It is used in some universities and computer center, but not in industries. In
IBM. It is more powerful than FORTRAN. It requires a very large compiler. It is a multipurpose
language suitable for both scientific and business applications. It has features of both FORTRAN and
COBOL.
Intel in 1975. A programmer can write programs for Intel 8080/8085 in PL/M faster than assembly
language directly. PL/M compiler is used with Intel micro development system. It is a microprocessor-
introduced in 1974 by Moore and Rather. It efficiently utilises the resources of a computer such as
memory space and CPU execution speed. Like C, it has features of assembly language. It is used by
APL. It has been developed by IBM. The abbreviation stands for A Programming Language. It
is a very powerful language. It allows users to define instruction. It has a large library of
predetermined functions. It requires a large computer to run. It is designed for mathematical work. It is
more powerful than FORTRAN; but it is very complex, and difficult to use.
ADA. It has been named after Ada Lady Lovelace. It was introduced in 1980 by CII-
Honeywell-Bull (France). It is a multipurpose language suitable for both scientific and business
applications. It combines the best features of PASCAL, ALGOL and PL/1 It also has the feature of
real-time multitasking required in control applications. As an engineers uses LSI devices to design a
digital system, one can use software components for writing complex programs.
also allows programmer to manipulate internal registers of the processor. It is a powerful, flexible and
very efficient language. It is used in writing operating system and software package.
PROLOG. It stands for Programming Logic. It is new language suitable for artificial
intelligence. It was developed in 1972 at the University of Marseillers. It is capable of handling large
databases.
LISP. It stands for List Processing. It was developed in early 1960s by McCarthy. This language
is also suitable for artificial intelligence. Both PROLOG and LISP are excellent language for artificial
intelligence application. PROLOG needs less memory space than LISP and hence PROLOG preferred
where memory space is limited. LISP is more powerful in I/O handling and graphics
SNOBOL. It stands for String Oriented SymBOlic Language. It was developed in mid 1960s. It
can manipulate strings of characters and hence, it is used for text processing.
LOGO. It was developed at MIT in the late 1960s by Seymour Papert and his colleagues It has
been used in Universities for complex scientific problems. It has also been used for children as
educational language to achieve intellectual growth and problem solving skills. Logo has graphic
features. Children can draw, color and animate images. It can also be used to compose music,
APT. It stands for Automatically Programmed Tooling. It is used to control machine tools in
manufacturing applications.
PILOT. It stands for Programmed Inquiry Learning Or Teaching. It is used in the preparation of
computer-assisted instructions.
structured language. Its compiler finds programming errors more easily as compared to the compilers
of other languages
2. The writing of program in a high-level language is easier and faster than the writing of
3. Programs in high-level languages are portable i.e. they can run on any computer or
4. Easier documentation.
5. The program is independent of the structure of a particular computer. The program is problem
6. Standard syntax.
1. One has to learn the special rules for writing programs in a particular high-level language.
machine language. Hence the high-level language takes more time to produce result -i.e.
3. Low efficiency of memory utilization. A program in high-level language occupies a larger part
of the memory.
2.8 Stacks:
The registers are required for some other operation in subsequent steps. These contents are
moved to certain memory locations by PUSH operation. Then the registers are used for other
operations. After completing these operations those contents which were saved in the memory are
transferred back to the registers by POP operation. Memory locations for this purpose is set aside by
the programmer in the beginning. The set of memory locations kept for this purpose is called stack.
The last memory location of the occupied portion of the stack is called stacktop.
A special 16-bit register known as stack pointer holds the address of stacktop. The stack
pointer is initialized in the beginning of the program by LXI or SPHL instruction. Any area of the
RAM can be used as stack. There is no restriction on the location of the stack in the memory. Data are
Fig. 5.1 shows a typical stack and stacktop location. The SP register holds the address of
stacktop location. Fig. 5.2 (a) shows the position of a stack before PUSH operation. Suppose the
contents of the register pair B-C is to be pushed. After PUSH operation the stack position has been
shown in Fig. 5.2 (b). Similarly, POP operation is used to transfer the contents from the stack to the
register. The stack position before and after the POP operation has been shown Fig. 5.3 (a) and (b)
respectively.
2.9 Subroutines:
While writing a program certain operations may occur several times and they are not available
as individual instruction. The program for such operations are repeated again and again in the main
program. A simple example of such operation is multiplication. The Intel 8085 does not have any
instruction for multiplication and hence, a program is written to perform multiplication. Similarly,
small programs are written for functions like sine, cosine, logarithm, square root etc. the concept of
The small program for a particular task is called subroutine. Subroutines are written separately
and stored in memory. They are called at various points of the main program by CALL instruction
where they are required. The last instruction of the subroutines is RET. After the completion of a
subroutine, the main program begins from the instruction immediately following the CALL
instruction. The techniques of subroutine saves memory locations. Fig. 5.4 shows a call-return
structure.
2.10 MACRO:
A sequence of instructions to which a name is assigned is called a Macro. The name of the
macro is used in assembly language programming. The macro facility is available with many
assemblers. Each macro is clearly defined and unique name is assigned to it.
Example 1:
LXI H, ADDRESS
MOV A, M
CMA
ENDM
In the above example COMPILE is the name of the macro. MACRO is written in the beginning of the
definition as shown in example1. ADDRESS is a parameter. ENDM is used to end the macro. If we
write COMPLE 2500H in an assembly language program, the assembler will replace this macro by
LXI H, 2500H
MOV A, M
CMA
This sequence of instruction will take the complement of the content of the memory location 2500H.
2.11 Microprogramming:
The CPU places the content of the program counter on the address but to fetch the opcode of
The CPU reads the opcode from the memory and places it in the instruction register.
The CPU takes other data, if necessary, from the memory or other register to execute the
instruction.
The CPU increments the content of the program counter so that it will be able to fetch the next
instruction.
hardwired CPU logic circuits produce the required sequence of operations to execute an instruction.
This is a hardware approach to control the above mentioned operations. The same sequence of
operations can also be performed using software. To execute each step there is a micro operation. To
The hardware of a computer system can’t do anything by itself; software is required to direct it
what to do. The system software is a collection of programs written for a computer which allows user
to develop and run his program. The system software is stored in ROM/Disks. It includes operating
system, BIOS, assembler, compiler, editor, etc. an operating system is a collection of programs. It
a) Monitor:
A monitor is a program which resides in a ROM or PROM. It carries out the following functions:
In a microprocessor kit a monitor controls its entire operation. It contains subroutines for debugging
programs. It also contains commands like INSERT, DELETE, DELAY, RELOCATE etc. it controls
b) Operating System:
responsible for managing files on the disks and communication between the computer and peripherals,
memory space management etc. it is a program or collection of program which are usually stored on
disks. The operating system stored on disk is called Disk Operating System (DOS).
Write programs and data into files; edit them and store them
Debugging of programs
File Manager: File Manager is a program which allows user to create, delete, copy or update files on
the disks. The term files refers to the collection of information supplied by the programmer. Which is
Linker: A large program is divided in smaller programs known as modules. It is easier to develop, test
and debug smaller programs. A linker is a program which links smaller programs together to form a
large program. The linker also links these subroutines with the main program. The linker links object
code(machine codes)program.
Locator: A locator is a program which assigns specific memory addresses for the machine codes of
Debugger: Debugger is a program which allows user to test and debug the programs. All computers
including microprocessors kits provide debugging facility. To detect errors a program can be tested in
Assembler or Macro assembler: An assembler or Macro assembler generally forms a part of the
c) Text Editor:
A text editor is a program which allows user to write source program or text into RAM. The
user write his program in assembly or high level language in proper format. A program written in these
language in the proper format is known as source program. The typing or program errors are easily
corrected using the commands of the editor. The use can add or delete lines anywhere in the program
System software:
The software require for running user programs is known as system software. It includes
Application software:
Special purpose software written for specific use is known as application software. Examples
of application software (or program) are accounting packages, data base management packages and
Utility program: These are software tools which help users in developing, writing, debugging and
documenting programs.
In a multiuser system a number of terminals are connected to a single CPU. Several users work
In industrial applications a number of tasks are handled by the CPU. The term multitasking is
used in real-time industrial applications. They are attended on priority basis. A low priority task can be
CPU must take up these tasks in a scheduled manner so that they are executed properly. The part of the
operating system which manages scheduling work is known as scheduler, dispatcher or supervisor.
f) Windows:
user a graphical interface for application program. It has been developed for personal computer.
Windows can use virtual memory resources as well. It promises more than 1000 enhancements, fast
speed and ease of use. Today, in almost all environment related to management, finance, sales,
marketing, development and other general office functions need a rapid access to information and
g) UNIX:
UNIX is a multiuser system. It allows several users to share a CPU on time share basis. It
contains three layers. The innermost layer is known as kernel. It contains scheduler and a hierarchical
file structure. The middle layer of the operating system is known as shell which contains the command
interpreter. It decodes and carries out the user-entered commands. The outermost layer contains
programming tools such as assembler, editer, debugger, compiler and application packages.
Example 1.
Program:
Address Codes
The instruction MVI B, 05 moves 05 to register B. HLT halts the program. A program is fed to
microprocessor kit in machine codes. The machine code for the instruction MVI B, 05 is 06, 05. the
1st byte of the instruction is 06 which is the machine code for the instruction MVI B. the code for HLT
is 76. this program can be executed on a microprocessor kit and the register B can be examined. After
Example 2.
Program:
Address Codes
The instruction MVI A, 05 will moves 05 to register A. in the code form it is written as 3E, 05.
the1st byte of the instruction is 3E. this code is for MVI A. the second byte 05 is the data which is to
Example 3.
Object: Load the content of the memory location FC50 H directly to the accumulator, then transfer it to
Program:
Address Codes
FC00 3A,50,FC LDA FC50 Get the content of the memory location
The instruction LDA loads the accumulator directly with the content of the memory location
specified in the instruction. Thus the instruction LDA FC50 will load the accumulator with the content
of the memory location FC50 H. the instruction MOV B,A will move the content of the accumulator to
B. the content of the memory location FC50 H is 05. after the execution of the program the register B
Example 4.
Object: Place the content of the memory location FC50 H in register B and that of FC51 H register C.
Program:
Address Codes
The instruction LXI H,FC50 H will place FC50 H in H-L pair. FC50 H is the address of the
memory location which contains 11 H. MOV B, M will move the content of FC50 H to register B. the
instruction INX H will increase the content of H-L pair by 1. the execution of the instruction INX H
will increase the content of H-L pair from FC50 to FC51 H. MOV C, M will move the content of FC51
H to register C. thus after the execution of the program the register B and C will contain 11 H and 12
H respectively.
Problem:
Add 49 H and 56 H
Address Codes
2000 21,01,25 LXI H, 2501H Get address of 1st number in H-L pair.
2009 76 HLT
Data
2501 - 49 H
2502 – 56 H
Result
2503 – 9F H
2501 H is the address of the memory location for the 1 st number. 2501 is placed in H-L pair by the
instruction LXI H, 2501 H. the next instruction is MOV A, M which moves the content of the memory
location addressed by H-L pair to the accumulator. In this case H-L pair contains 2501 H and,
therefore, the content of the memory location 2501 H is moved to the accumulator. Thus the 1 st
number 49 H has been moved to the accumulator. The instruction INX H increases the content H-L
pair by one. After the execution of INX H it becomes 2502 H. ADD M adds the content of the
accumulator and the content of the memory location addressed by H-L pair. The content of 2502 H is
the 2nd number 56 H. so 56 H is added to 49 H. sum resides in the accumulator. The instruction STA
2503 H stores the sum in the memory location 2503 H. the instruction HLT ends the program.
Example
49 H 1st number
Result:
17 H
Program
Address Codes
H-L pair.
2503 H
2009 76 HLT
Data
2504 - 49 H
2505 – 32 H
Result
2506 – 17 H
The 1st number is in the memory location 2501 is placed in H-L pair by the execution of the
instruction LXI H, 2501 H. the instruction is MOV A, M moves the content of the memory location
addressed by H-L pair to the accumulator. Thus the 1 st number 49 H which is in 2501 H is placed in
the accumulator. INX H increases the content H-L pair from 2501 to 2502 H. the instruction SUB M
subtracts the content of the memory location addressed by H-L pair from the accumulator. The 2 nd
number which is in the memory location 2502 H is subtracted from the 1 st number which is in the
accumulator. The result resides in the accumulator. The INX H increase the content of H-L pair from
2502 to 2503 H. the instruction MOV M, A transfer the content of the accumulator to the memory
location addressed by H-L pair. So the result is in the accumulator is stored in the memory location
Example
Add 98 H and 9A H
Sum = 01, 32 H
Program
Address Codes
AHEAD
Data
2501 – 98 H
2502 – 9A H
Result
The 1st instruction of the program LXI H,2501 H get the address of the 1 st number in H-L pair.
The MSBs of the sum is placed in register C. the initial value of the MSBs of the sum is kept 00. MOV
A, M transfers 1st number from the memory location 2501 H to the accumulator. INX H increases the
content of H-L pair from 2501 to 2502 H. the 2 nd number is in 2502 H. ADD M adds 1 st and 2nd
number. After the execution of the instruction JNC the instruction INR C is executed if the addition
two numbers produces a carry. The register C contains the MSBs of the sum. The accumulator
contains LSBs of the sum. The instruction STA 2503 H places the LSBs of sum in memory location
2503 H. the instruction MOV A, C move the MSBs of the sum from register C to the accumulator.
The instruction STA 2504 H stores the MSBs of the sum in 2504 H.
After the execution of the instruction JNC the program jumps to label AHEAD and executes
STA 2503 H. if the addition of two numbers does not produces a carry. The LSB of the sum is placed
in memory location 2503 H. Register C contains 00, so the execution of the instruction MOV A, C
transfers 00 in the accumulator. The instruction STA 2504 H stores 00 in the memory location 2504 H.
Example 1
Program
Address Codes
2009 D2, OD, 20 JNC AHEAD Is carry? No, go to the label AHEAD
Data
2501 – 84 D
2502 – 74 D
Result
Example
sum 00, E 9 E 4 H
Program
Address Codes
200E 22,05,25 AHEAD SHLD 2505 H Store LSBs of the sum in 2505 & 2506.
Data
Result
Example
96 D 1st number
- 38 D 2nd number
-------------------------------
Result : 58 D
Program
Address Codes
2000 21,02,25 LXI H, 2502 H Get address of 2nd number in H-L pair.
Data
2501 – 96
2502 – 38
Result
2503 - 58
The instruction LXI H,2502 H places the address of the 2 nd number in H-L pair. MVI A,99
places 99 D in the accumulator. SUB M subtracts the 2 nd number (placed in 2502H) from 99 D to get
9’s complement of the 2nd number. INR A increments the content of the accumulator. Thus 10’s
complement of the 2nd number is obtained. DCX H decrements the content of the H-L pair to obtain the
address of the 1st number. ADD M adds 10’s complement of the 2 nd number to the 1st number. After
addition the result is in hexadecimal. The instruction DAA is used to get the result in decimal system.
The result is stored in the memory location 2503 H. the instruction HLT ends the program.
Example
Find one’s complement of 96 H. the number in the binary form is represented as follows:
96 H = 1001 0110
(9) (6)
(6) (9)
Program
Address Codes
Data
2504 – 96 H
Result
2502 - 69 H
The instruction LDA 2501 H transfers the number from memory location 2501 H to the
accumulator. CMA takes complement of the number. STA 2502 H stores the result in the memory
Example
Program
Address Codes
Data
Result
The 8 LSBs of the number are in the memory location 2501 H. The address 2501 is placed in
H-L pair. The 8 LSBs of the number are transferred from 2501 H to accumulator. The instruction
CMA takes one’s complement of 8 LSBs. The 8 LSBs of the result are stored in the memory location
2503 H. the address of 8 MSBs of the number is 2502 H, and it is placed in H-L pair. The 8 MSBs of
the number are transferred from 2502 H to the accumulator. The instruction CMA takes one’s
complement of 8 MSBs. The 8 MSBs of the result are stored in memory location 2504.
Example
Find one’s complement of 96 H. the number in the binary form is represented as follows:
96 H = 1001 0110
(9) (6)
(6) (9)
+ 0000 0001
---------------------
(6) (A)
Two’s complement of a number is obtained by adding 1 to the 1’s complement of the number.
Program
Address Codes
Data
2501 - 96 H
Result
2502 - 6A H
Example
-------------------------------------
Program
Address Codes
2000 21,01,25 LXI H, 2501H Address of 8 LSB’s of the number 2003 06, 00 MVI
Data
Result
Example
65 = 0110 0101
(6) (5)
result of shifting
(C) (A)
To shift a number left by one bit the number is added to itself or it is doubled. If 65 is added to 65, the
65 = 0110 0101
+ 65 = 0110 0101
--------------------
1100 1010 = CA
Program
Address Codes
Data
2501 - 65 H
Result
2502 – CA H
The instruction LDA 2501 H transfers the number from memory location 2501 H to the accumulator.
ADD A adds the contents of the accumulator to itself. The result is twice the number and thus the
Example
15 = 0001 0101
(1) (5)
(2) (A)
(5) (4)
The shifting of a number left by two bits can be achieved the number to itself and again adding the
Program
Address Codes
Data
2501 - 15 H
Result
2502 – 54 H
Example
Program
Address Codes
2004 22, 03, 25 SHLD 2503H store result in 2503 and 2504 H
Data
Result
The 16-bit number has been placed in two consecutive memory locations 2501 and 2502 H. the
instruction LHLD 2501 H transfers the 16-bit number from 2501 and 2505 H to H-L pair. DAD H is
an instruction for 16-bit addition. It adds the content of H-L pair itself. The 16-bit number is shifted
left by one bit. the 16-bit result is stored in the memory locations 2503 and 2504 H by SHLD
instruction.
Example
Program
Address Codes
2005 22, 03, 25 SHLD 2503 H store result in 2503 and 2504 H
Data
Result
Example
Number = A6
= 1010 0110
(A) (6)
(A) (0)
To mask off the least significant 4 bits of a given number. The LSD of the given number A6 is
[Link] is to be cleared (masked off). The MSD of the number A6 is A. in the binary form it is 1010. it is
not to be affected. If this number is multiplied by 1111. it will not be affected. Similarly the LSD of
the number is 6. in the binary form it is represented by 0110. if it is multiplied by 0000. it becomes
0000.i.e it is cleared. Thus if the number A6 is multiplied by F0, the LSD of the number is masked
off.
Program
Address Codes
Data
2501 - A6
Result
2502 - A0
The instruction LAD 2501 H transfer the content of memory location 2501 H i.e. the given
number to the accumulator. ANI F0 logically ANDs the content of the accumulator with F0 to clear
the least significant 4 bits of the number. STA 2502 H stores the result in memory locations 2502 H.
Example
Number = A6
= 1010 0110
(A) (6)
(0) (6)
To mask off 4 most significant of a number. 4 MSBs are multiplied by 0000. the least
significant bits are not to be affected and, therefore, they are multiplied by 1111. i.e. F. thus if an 8-bit
Program
Address Codes
Data
2501 - A6
Result
2503 -06
The instruction LAD 2501 H transfer the content of memory location 2501 H to the
accumulator. ANI F0 logically ANDs the content of the accumulator with F0 to clear the most
significant 4 bits of the number. STA 2502 H stores the result in memory locations 2502 H. HLT
Example
The numbers are represented in hexadecimal system. The 1 st number is moved from its memory
location to the accumulator. It is compared with 2 nd number. The larger of the two is then placed in the
accumulator. From the accumulator the larger number is moved to the desired memory location.
Address Codes
Go to AHEAD
2009 7E MOV A, M Yes, get 2nd number in accumulator 200A 32, 03,25 AHEADSTA
Data
2501 - 98 H
2502 – 87 H
Result
The 1st step of the program is LXI H, 2501 H. the address of the memory location of the 1 st
number is 2501 H. i.e. 2501 is placed in H-L pair. The next instruction of the program is MOV A, M.
the execution of this instruction moves the content of the memory to the accumulator. Now the 1 st
number i.e. 98 is in the accumulator. INX H increases the content of H-L pair by 1. the content of H-L
pair is increased from 2501 to 2502. the address of the memory location for 2 nd number is 2502. the
instruction CMP M means that the content of the memory location 2502 is compared with the content
of accumulator. The instruction JNC is executed and the program jumps to the instruction STA 2503.
the larger number is in the accumulator. The instruction STA 2503 H stores the larger number.
Example
The numbers in a series are : 98, 75 and 99. the numbers are placed in the memory
location 2501 to 2503 H. the result is stored in the memory location 2504 H.
The 1st of the series is placed in accumulator and it is compared with the 2 nd number. The
larger of two number is placed in the accumulator. Again this number is placed in the accumulator is
compared with the 3rd number of series and larger number is placed in the accumulator. All the
numbers of the series are compared and the largest number is stored in the desired memory location.
Program
Address Codes
previous maximum.
maximum?
accumulator.
Data
2500 - 03 (count)
2501 - 98
2502 - 75
2503 - 99
Result
2450 - 99
The memory location 2500 H contains the count of the series. 2500 H is placed in H-L pair.
The next instruction MOV C, M places the count in register C. INX H increase the content of H-L pair
by one. Now 2501 is in H-L pair. The 1 st number of the series resides in the memory location 2501 H.
MOV A, M moves the 1st number (98) in accumulator. DCR C decreases the count from 03 to [Link]
means that now there are two more numbers in series. INX H increases the content of the H-L pair
from 2501 to 2503 H. the 2nd number of the series is in the memory location 2502 H. CMP M
compares content of the accumulator(1st number) with the content of 2502 H(2nd number).
The 1st number 98 is greater than the 2nd number 75, there will be no carry. The instruction JNC
will be executed and program will move the label AHEAD. The count will be decreased from 02 to 01.
it indicates that now there is one number left in the series. As the content of register C is not zero. The
program will move to the label LOOP. The INX H will change the content of H-L pair from 2502 to
2503 H. 2503 H is the address of memory location for 3 rd number. Again CMP M will compare the
content of accumulator (98) with the content of 2503 H. the content of 2503 H is 99 which is greater
than the content of accumulator. In this case there will be a carry. After JNC instruction the program
will take up the instruction MOV A, M the larger number (99) will move from the memory location
2503 H to accumulator. DCR C will reduce the content of register C from 01 to 00. as the content of
register C is 00, the program will not jump to the label LOOP. The instruction STA 2450 H will
executed. The largest number (99) which is in the accumulator will be stored in the memory location
3.20 An Alternative Program To Find the Largest Number from a series of Number
Example
The numbers in a series are : 98, 75 and 99. the count is store din memory location 2500
H. the numbers are placed in the memory location 2501 to 2503 H. the result is stored in the memory
location 2450 H.
Program
Address Codes
the series
maximum?
Data
2504 - 03 (count)
2505 - 98
2506 - 75
2507 - 99
Result
2450 - 99
The memory location 2500 H contains the count of the series. 2500 H is placed in H-L pair.
The instruction MOV C, M places the count in register C. in example count is 03. the instruction SUB
A makes the content of accumulator 00. As 00 is the smallest 8-bit number, it is taken as initial value
for comparison. INX H point out the 1st number of the series. CMP M compares 1st number with 00. as
the 1st number with 00. as the 1 st number is greater than 00, there is a carry, and after the execution of
JNC, the instruction MOV A, M is executed. The first number i.e. 98 is now transferred to the
accumulator. Then the count in register C is decremented and the program is transferred to the label
LOOP. Then INX H point the address of the 2 nd number of the series(75). The 1 st number (98) is larger
than 2nd number, there is no carry, and after the execution of the instruction JNC the program jumps to
the label AHEAD. The 1st number being the larger number is retained in accumulator. The count is
decremented and program jumps to LOOP again process the third number of the series.
Order)
Example
Program
Address Codes
in register D
2008 23 INX H
200D D2, 16, 20 JNC AHEAD if previous greatest number > next
number, go to AHEAD
2010 2B DCX H
numbers in memory
numbers in accumulator
numbers in memory
2018 23 GO INX H
Data Result
2500 – Count 04
2501 – 60 15
2502 – 40 25
2503 – 50 40
2504 – 15 50
2505 – 25 60
Example
The numbers are represented in hexadecimal system. The 1 st number is moved from its memory
location to the accumulator. It is compared with 2 nd number. The smaller of the two is then placed in
the accumulator. From the accumulator the smaller number is moved to the desired memory location.
Program
Address Codes
accumulator. Go to AHEAD
accumulator
200A 32, 03,25 AHEAD STA 2503H 4 Store smaller number in 2503 H.
Data
2502 - 84 H
2502 – 99 H
Result
2501 H is the address of the memory location for the 1 st number. The instruction LXI H, 2501
H places 2501 H in H-L pair. The next instruction MOV A, M moves the content of the memory
instruction INX H increases the content of H-L pair from 2501 to 2502 H. the instruction CMP M
compares the content of the accumulator(1 st number) with the content of the memory location 2502
H( 2nd number).if the 1st number is smaller than the 2nd number. There is a carry. The instruction JC is
executed and the program jumps to STA 2503 H. the smaller number (84 H) is in the accumulator and
the instruction STA 2503 H stores it in the memory location 2503 H. the instruction HLT will end the
program.
Example
The 1st number of the series is placed in the accumulator and it is compared with the 2 nd
number in which is in the memory. The smaller of the two is placed in the accumulator. Again this
number which is in the accumulator is compared with the 3 rd number of series and smaller number is
placed in the accumulator. This process of comparison is repeated till all the numbers of the series are
compared and the smallest number is stored in the desired memory location.
The memory location 2500 H contains the count of the series. Count is 03. 2500 is placed in H-
L pair. The instruction MOV C, M places the count in register C. INX H increases the content of H-L
pair from 2500 to 2501 H. the first number of series resides in the memory location 2501 H. MOV A,
M moves the 1st number (86) in the accumulator. DCR C decreases the count from 03 to 02, INX H
increases the content of H-L pair from 2501 to 2502 H. the 2 nd number of the series is in 2502 H. CMP
M compare the content of the accumulator(1 st number) with the content memory location 2502 H(2 nd
number).
The 1st number is greater than the 2 nd number 58. there is no carry, the instruction MOV A, M
will be executed. The small number 58 will be placed in the accumulator. DCR C will decrease count
from 02 to 01. the content of register C is non zero, the program will jump to the label LOOP. The
INX H will change the content of H-L pair from 2502 to 2503 H. the third number of series is in 2503
H. again CMP M will compare the content of accumulator (58) with the content of 2503 H. the content
of 2503 H is 75 which is greater than the content of accumulator. There will be a carry. After the
execution of instruction JC AHEAD the program will jump to the label AHEAD. The content of the
accumulator will remain as it is. DCR C will reduce the count from 01 to 00. the content of register C
is zero. Program will not jump. The smallest number (58) is in the accumulator will be stored in the
memory location 2450 H. the instruction HLT will end the program.
Program
Address Codes
2000 21,00,25 LXI H, 2500 H Get address for count in H-L pair
next number?
Go to AHEAD
2011 32, 50,24 AHEAD STA 2450 H Store smaller number in 2450 H.
Data 2500 – 03
2501 – 86 H
2502 – 58 H
2503 – 75 H
Result
2450 - 58 H
Example
The number of a series are: 86, 58 and 75. there are three numbers in the series, count = 03. the
count is stored in the memory location 2500 H. the numbers are stored in the memory location 2501 to
2503 H.
Program
Address Codes
2000 21,00,25 LXI H, 2500 H Get address for count in H-L pair
accumulator. Go to AHEAD.
accumulator
2010 32, 03,25 AHEAD STA 2450 H Store smaller number in 2450 H.
Data
2500 - 03 H
2501 – 86 H
2502 – 58 H
2503 – 75 H
Result
2450 - 58 H
The memory location 2500 H contains the count of the series. 2500 H is placed in H-L pair.
MOV C, M, M transfer the count to register C. MVI A, FF brings FF into the accumulator. As FF is
the largest 8-bit number, it is taken an initial number for comparison. INX H points out the address of
the 1st number. CMP M compares the content of the accumulator i.e. FF with the 1 st number (86
example). As FF is greater than 86, there is no carry. After the execution of the instruction JC, the
instruction MOV A, M is executed to transfer the 1 st number(86) to the accumulator. Then the count is
decremented and the program jumps to the label LOOP. Now INX H points out the address of the 2 nd
number(58 H). As58 H is smaller than 86H, 58 H is transferred to the accumulator. Again the count is
decremented and the program goes back to the label LOOP. This time INX H points out the 3 rd
number (75 H). As 58 is smaller than 75, there will be a carry. After the execution of JC the program
will jump to AHEAD, and the count will be decremented. 58 H will remain in the accumulator. The
smallest number of the series is obtained and stored in the memory location 2450 H.
Example
The initial value of the sum is made 00. the number of the series are taken one by one and
Program
Address Codes
2400 21,00,25 LXI H, 2500 H Address for the count in H-L pair
Data
2500 - 04 H
2501 – 16 H
2502 – 2B H
2503 – 39 H
2504 - 12 H
Result
2450 - 8C H
Example
The numbers are placed in the memory locations 2501 to 2504 H, and count in 2500 H.
As there are 4 numbers in the series, count = 04. The initial value of the sum is made 00. the
number of the series are taken one by one and added to the sum.
Program
Address Codes
2400 21,00,25 LXI H, 2500 H Address for the count in H-L pair
2411 32, 50, 24 STA 2450 H Store LSBs of the sum in 2450 H
Data
2500 - 04 H
2501 – 45 H
2502 – 98 H
2503 – 8A H
2504 - E2 H
Result
The count is placed in register C. the LSBs of the sum reside in the accumulator, and MSBs of the sum
in register B. initial value of the LSBs and MSBs of the sum are made 00. the 1 st number is added to
the initial sum. Count is decreased by one and the program jumps to LOOP. The address of the 2 nd
number is placed in H-L pair. ADD M adds 2 nd number to the previous sum which is in the
accumulator. If there is any carry after addition, that is stored in register B. the process is repeated and
the remaining numbers of the series are added. The LSBs of the sum is stored in memory location
Example
Add 65, 46, 35 and 98 D. these are decimal numbers. D stands for decimal.
Sum = 0244 D
The instruction DAA is used in the program for decimal adjustment. It is used after ADD
instruction.
Program
Address Codes
2400 21,00,25 LXI H, 2500 H Address for the count in H-L pair
2411 32, 50, 24 STA 2450 H Store LSBs of the sum in 2450 H
Data
2500 - 04 H
2501 – 65 H
2502 – 46 H
2503 – 35 H
2504 - 98 H
Result
Example
These are hexadecimal numbers. The dividend is a 16-bit number and divisor 8-bit number. If the
dividend of a problem is an 8-bit number. it is extended to a 16-bit number by placing zeros in MSBs
positions.
The results are stored in the memory location 2504 and 2505 H
Program
Address Codes
accumulator
of dividend
2415 22, 04, 25 SHLD 2504 H Store quotient in 2504 and remainder
in 2505H
Data
2503 – 1A H, Divisor
Result
The count register C is kept 08. the trial subtraction is done 8 times and an 8-bit quotient is
obtained. The instruction DAD H shifts dividend and quotient left by one bit. Due to shift of dividend
the bit positions in register L fall vacant. In the vacant bit positions quotient is stored. The MSB of the
dividend should be zero. Otherwise it will be shifted to carry bit. If a problem contain MSB not equal
to zero. It will be solved by splitting it in two parts. Shifting of dividend before subtraction is not done
in ordinary division.
Example
3 A 9 C 8 A 6 7 H, 1st Number
+ 9 B 4 7 6 C 8 B H, 2nd Number
------------------------------------------
D 5 E 3 F 6 F 2 H, Sum
A byte consist of 8-bits. The above example two multibyte hexa numbers are to be added. Each
number consist of 4 bytes. An 8-bit microcomputer takes one byte of the numbers at a time and adds
them with carry. A counter is initiated to count the byte. In example count = 4.
Program
Address Codes
2405 11, 01, 26 LXI D, 2601 H Address of 1st byte of 2nd number
number + carry
by H-L pair.
Data
2500 – 04
2501 – 67 2601 – 8B
2502 – 8A 2602 – 6C
2503 – 9C 2603 - 47
2504 – 3A 2604 – 9B
Result
2501 – F2
2502 – F6
2503 – E3
2504 – D5
Example
E C 8 B 9 4 5 A 1st Number
- 4 B 3 C A 8 B 9 2nd Number
------------------------
Department of Computer Science, Thanthai Hans Roever College, Perambalur
Microprocessor and It’s Applications 123
A14EEBA1
Program
Address Codes
2405 11, 01, 26 LXI D, 2601 H Address of 1st byte of 2nd number
by H-L pair.
Data
2500 – 04
2501 – B9 2601 – 5A
2502 – A8 2602 – 94
2503 – 3C 2603 – 8B
2504 – 4B 2604 – EC
Result
2501 – A1
2502 – EB
2503 – 4E
2504 – A1
Example
Program
Address Codes
LOOP2 MVI B, 00
LXI H, 4150
MOV C, M
DCR C
INX H
MOV A, M
LOOP INX H
CMP M
JC LOOP1
MOV D, M
MOV M, A
DCX H
MOV M, D
INX H
MVI B, 01
LOOP1 DCR C
JNZ LOOP
DCR B
JZ LOOP2
HLT
Data
4150 - 03
4151 – 0A
4152 – 08
4153 – 0B
Result
4151 - 08
4152 – 0A
4153 – 0B
Example
Program
Address Codes
LOOP2 MVI B, 00
LXI H, 4150
MOV C, M
DCR C
INX H
MOV A, M
LOOP INX H
CMP M
JNC LOOP1
MOV D, M
MOV M, A
DCX H
MOV M, D
INX H
MVI B, 01
LOOP1 DCR C
JNZ LOOP
DCR B
JZ LOOP2
HLT
Data
4150 - 03
4151 – 0A
4152 – AA
4153 – 0C
Result
4151 - AA
4152 – 0C
4153 – 0A
4.1 Introduction
The microprocessor is the heart of a microcomputer. Memories and input/output devices are interfaced
Intel 8085 uses a 16-bit wide address bus for addressing memories and I/O devices. Using 16-
bit wide address bus it can access 216 = 64K bytes of memory and I/O devices. There are two schemes
In Memory Mapped I/O scheme there is only one address space. Address space is defined as
the set of all possible addresses that a microprocessor can generate. Some addresses are assigned to
memories and some addresses to I/O devices. Suppose memories locations are assigned the addresses
2000 to 24FF. one address is assigned to each memory location. Any one of these addresses cannot be
assigned to I/O device. The addresses for I/O devices are different from the addresses which have been
All the data transfer instructions of the microprocessor can be used for both memory as well as
I/O devices. For example, MOV A, M will be valid for data transfer from the memory location or I/O
device whose address is in H-L pair. If the H-L pair contains the address of memory location, data will
In this scheme the addresses assigned to memory locations can also be assigned to I/O devices.
Since the same address may be assigned to a memory location or an I/O device. The microprocessor
must issue a signal to distinguish whether the address on the address bus is for a memory location or
an I/O device. When the signal is high the address on the address bus is for an I/O device. When the
signal is low the address on the address bus is for a memory location. Two extra instructions IN and
OUT are used to address I/O devices . The IN instruction is used to read the data of an input device.
Several memory chips and I/O devices are connected to a microprocessor. Fig. 7.1 shows a
schematic diagram to interface memory chips or I/O devices to a microprocessor. An address decoding
circuit is employed to select the required I/O device or a memory chip. Fig 7.2 shows a schematic
diagram of a decoding circuit. If IO/M’ is high the decoder 2 is activated and the required I/O device is
selected.
Memory Interfacing:
The address of a memory location or an I/O device is sent out by the microprocessor. The
corresponding memory chip or I/O device is selected by a decoding circuit. A 1 to 8 lines decoder will
be illustrated. Fig. 7.3 shows the interface of memory chips through 74LS138.G1, G2A and G2B are
enable signals. To enable 74LS138, G1 should be high, and G2A and G2B should be low. A, B and C
are select lines. By applying proper logic to select lines any one of the outputs can be selected. Y0,
Y1….Y7 are 8 output lines. An output lines goes low when it is selected. Other output lines remains
high. Table 7.1 shows the truth table for 74LS138. when G1 is low or G2A is high or G2B is high, all
output lines become high. Thus 74LS138 acts as decoder only when G1 is high, and G2A and G2B are
low.
The memory locations for EPROM 1 will lie in the range 0000 to 1FFF. These are the memory
locations for ZONE 0 for the memory chip which is connected to the output line Y0 of the decoder.
Similarly for ZONE 1 is 2000 to 3FFF and for ZONE 7 is E000 to FFFF. Table 7.2 shows the memory
The entire memory address (64K for 8085) has been divided into 8 zones. Address lines A 15,
A14 and A13 have been applied to the select lines A, B, and C of the 74LS138. the logic applied to these
lines selects a particular memory device, an EPROM or a RAM. Other address lines A 0, A1, A2……A12
go directly to the memory chip. IO/M’ is connected to G2B. when IO/M’ goes low for memory
read/write operation. G2B goes low. G1 is connected to +5Vd.c, supply and G2A is grounded.
I/O Interfacing:
Fig 7.4 shows the interface of I/O devices through decoder 74LS138. as the address of an I/O
device is of 8-bits,only A8-A15 lines of address bus are used for I/O addressing. The address lines A 8,
A9 and A10 have been applied lines A, B and C of the 74LS138. the address lines A11-A15 are applied to
G2B through a NAND gate. G2B becomes low only when all address lines A 11-A15 are high. G2A is
grounded. IO/M’ is connected to G1. when IO/M’ goes high for I/O read/ write Operation. G1 goes
high.
devices such as microprocessor and memory, microprocessor and I/O devices, and memory and I/O
devices. Usually, memories are compatible with microprocessor because the same technology is
A microprocessor-based system or a computer may have several I/O devices of different speed.
A slow I/O device cannot transfer data when microprocessor issues instruction for the same because it
takes some time to get ready. To solve the problem of speed mismatch between a microprocessor and
I/O devices a number of data transfer techniques have been developed. The data transfer schemes are
In Programmed data transfer schemes are controlled by the CPU. Data are transferred from an
I/O deice to the CPU. The programs are executed by the CPU when an I/O device is ready to transfer
data. The microprocessor executes the program to transfer data programmed data transfer schemes are
employed when small amount of data are to be transferred. The programmed data transfer schemes are
Synchronous Data Transfer: Synchronous means “ at the same time.” The device which sends data
and the device with receives data are synchronized with the same clock. When the CPU and I/O
devices match in speed, this technique of data transfer is employed. The IN instruction is used to read
data from an input device or input port. The OUT instruction is used to send data from the CPU to an
output device or output port. As the CPU and the I/O device match in speed, the I/O device is ready to
Asynchronous Data Transfer: Asynchronous means “at irregular intervals”. In this method data
transfer is not based on predetermined timing pattern. This technique of data transfer is used when the
speed of an I/O device does not match the speed of the microprocessor. In this technique the status of
the I/O device i.e. whether the device is ready or not, is checked by the microprocessor before the data
are transferred. The microprocessor initiates the I/O device to get ready and then continuously checks
the status of the I/O device till the I/O device becomes ready to transfer data. When I/O device ready,
the microprocessor sends instructions to transfer data. This method of data transfer is also called
handshaking mode of data transfer because some signals are exchanged between the I/O device and
The microprocessor issues an initiating signal to the I/O device to get ready (or to start). When
I/O device becomes ready it sends signals to the processor to indicate that it is ready. Such signals are
Interrupt Driven Data Transfer: In this scheme the microprocessor initiates an I/O device to get
ready, and then it executes its main program. When I/O device becomes ready to transfer the data. It
sends a high signal to the microprocessor through a special input line called a interrupt line.
Fig. 7.7 shows the interfacing of an A/D converter to transfer data employing interrupt driven
data transfer scheme. The microprocessor sends first the start of conversion signal, S/C to the A/D
converter. Thereafter, the microprocessor executes its main program. A/D converter is a slow device
compared to a microprocessor. It takes some time to convert analog signal to equivalent digital
quantity. When A/D converter completes the task of conversion, it makes end of conversional signal,
E/C high. The E/C signal is connected to an interrupt line of the microprocessor. When interrupt line
goes high, the microprocessor takes all necessary steps to transfer data from the A/D converter. After
completing the data transfer the microprocessor returns back to execute the main program that it was
In DMA data transfer scheme CPU doest not participate. Data are directly transferred from an
I/O device to the memory vice versa. The data transfer is controlled by the I/O device or a DMA
controller. This schemes is large amount of data are to be transferred. If bulk data are transferred
through the CPU, I/O device which wants to send data using DMA technique, sends the HOLD signal
to the CPU. The CPU send a hold acknowledge signal to the I/O device to indicate that it has received
eth HOLD request and it will give up the busses in the next machine cycle. The I/O devices take over
the control of buses and directly transfers data to the memory or reads from the memory.
DMA data transfer scheme is a faster scheme as compared to programmed data transfer
scheme. It is used to transfer data from mass storage devices such as hard disk, floppy disks etc. DMA
Burst mode of DMA data transfer: A scheme of DMA data transfer, in which the I/O device
withdraws the DMA request only after all the data bytes have been transferred, is called burst mode
data transfer.
Cycle Stealing Technique: In this technique a long block of data is transferred by a sequence of DMA
cycles. In this method after transferring one byte or several bytes. The I/O device withdraw DMA
request.
The Intel 8085 has five interrupt inputs namely TRAP, RST 7.5, RST 6.5, RST 5.5 and INTR.
The TRAP has the highest priority, followed by RST 7.5, RST 6.5 and RST 5.5. The INTR has the
lowest priority. When interrupts are to be used they are enabled by software using the instruction EI
Fig. 7.8 shows the schematic diagram of interrupts of Intel 8085. The instruction EI sets the
interrupt enable flip-flop to enable the interrupts. The use of the instruction EI enables all the
interrupts. The instruction DI (Disable Interrupt) is used to disable interrupts. The DI instruction resets
the interrupt enable flip-flop and disables all the interrupts except nonmaskable interrupt TRAP, see
Fig. 7.8.
Hardware and Software Interrupts: Interrupt caused by I/O device are called hardware interrupt.
The normal operation of a microprocessor can also be interrupted by special instructions. Such
interrupt is called a software interrupt. RST instruction of the 8085 are used for software interrupt.
When RST instruction is inserted in a program. The program is executed up to the point where RST
The internal abnormal or unusual conditions which prevent the normal processing sequence of
When several I/O devices are connected to the INTR interrupt line, an external hardware is
used to interface I/O devices. The external hardware circuit generates RST codes to implement the
Interrupt Call-Locations: When an interrupt occurs the program is transferred to a specific memory
location. Then the monitor transfers the program from the specific memory location to a memory
location in RAM, from where the user can write the program for interrupt service sub-routine (ISS).
For TRAP, RST 7.5, 6.5 and 5.5 the program is automatically transferred to specific memory locations
without any external hardware. The necessary hardware is already provided within 8085. The specific
TRAP 0024
An interrupt for which hardware· automatically transfers the program to a specific memory location is
RST 7.5, 6.5 and 5.5: RST 7.5, RST 6.5 and RST 5.5 are maskable interrupts. These interrupts are
enabled by software using instructions EI and SIM (Set Interrupt Mask). The execution of the
instruction SIM enables/disables interrupts according to the bit pattern of the accumulator. Fig. 7.9
Bits 0 - 2 set/rest the mask bits of interrupt mask register for RST 5.5, 6.7 and 7.5. Bit 0 is for
RST 5.5 mask, bit 1 for RST 6.5 mask and bit 2 for RST 7.5 mask. If a bit is set to 1 the corresponding
interrupt is masked off (disabled). If it is set to 0, the corresponding interrupt is enabled. Bit 3 is set to
1 to make bits 0 - 2 effective. Bit 4 is an additional control for RST 7.5. if it is set to 1, the flip-flop for
Pending Interrupts: When one interrupt request is being served, other interrupt may occur resulting
in a pending request. When more than one interrupts occur simultaneously, the interrupt having higher
priority is served and the interrupts with lower priority remain pending. As 8085 contains several
interrupt lines; an interrupt may occur while other interrupt is being served resulting in a pending
interrupt.
Fig. 7.10 shows accumulator contents after the execution of instruction RIM. Bits 0-2 a for
interrupt masks; 1=masked. Bit 3 indicates interrupt enable flag; 1=enabled. Bits 4-6 indicate pending
To communicate with the outside world microcomputers use peripherals (I/O devices).
Commonly used peripherals are: A/D converter, D/A converter, CRT, printers, hard disk, floppy disks,
magnetic tapes etc. Peripherals are connected to the microcomputer through electronic circuits known
i. I/O port
v. Communication Interface
Examples of such devices are: CRT controller, Floppy Disk controller, Keyboard and Display
interface.
Generation of Control Signal for memory and I/O devices: Intel 8085 issues control signal RD’,
WR’ for read and write operation of memory and I/O devices. A status signal IO/M’ to distinguish
These control signals are generated using RD’ WR’ and IO/M’ using logic gates.
To get MEMR’ use IO/M v RD’. v is a symbol for logical OR operation. Memory read operation takes
place when IO/M’ and RD’ both are low. IO/M’ and RD’ are applied to an OR gate. The output of the
OR gate is MEMR’. When both IO/M’ and RD’ are low, MEMR’ goes low it activates memory for
read operation.
I/O read/write operation take place when IO/M’ is high. To get IOR’ and IOW’ signals IO/M’ is
An input device is connected to the microprocessor through an input port. An input port is a
place for unloading data. An input device unloads data into the port. The microprocessor reads data
from the input port. Thus data are transferred from the input device to the accumulator via input port.
Similarly, the output device is connected to the microprocessor through an output port. The
microprocessor unloads data into an output port. As the output port is connected to the output device,
data are transferred to the output device. Fig. 7.12 shows a schematic connection of CPU, I/O port, I/O
devices.
The Intel 8212 is an 8-bit nonprogrammable I/O port. It can be connected to the microprocessor
either as an input port or an output port. If we require one input port and one output port, two units of
8212 will be required. One of them will be connected in input mode and other in the output mode. Fig.
7.13 shows the connection of 8212 in input mode and output mode.
device. The ports may be programmed in a variety of ways as required by the programmer. The device
Example :
Intel 8255: The Intel 8255 is a programmable peripheral interface (PPI). It has two versions, namely
the Intel 8255A and the Intel 8255A-5. General descriptions for both are same. There are some
differences in their electrical characteristics. It has three 8-bit ports, namely Port A, Port B and Port C.
The Port C has been further divided into two 4-bit ports. Port C upper and Port C lower. Thus a total of
4 ports are available, two 8-bit port and two 4-bit ports. Each port can be programmed either as an
Architecture of Intel 8255A : Fig. 7.14 shows the pin diagram of Intel 8255A. it is a 40 pin I.C.
package.
IDR = Darlington drive current=Minimum 1 mA, Maximum 4 mA on any 8 pins of the port.
CS (Chip Select). It is a chip select signal. The LOW status of this signal enables
RD(Read). When RD goes LOW the 8255 sends out data or status information to the CPU on
the data bus. In other words it allows the CPU to read data from the input port of 8255.
WR (Write). When WR goes LOW the CPU writes data or control word into 8255. The CPU
writes data into the output port of 8255 and the control word into the control word register.
A0 and A1. The selection of input port and control word register is done using A0 and A1 in
conjunction with RD and WR. If two 8255 units are used the address of ports are as follows :
Port A 00
Port B 01
Port C 02
Port A 08
Port B 09
Port C 0A
Operating Mode of 8255: The Intel 8255 has the following three modes of operation which are
selected by software:
The 8255 has two 8-bit ports (Port A and Port B) and two 4-bit ports (Port Cupper and Port
Clower).
Mode 0 operation a Port can be operated as a simple input or output port. Each of the four ports
Mode 1 is strobed input/output mode of operation. The port A and Port B both are designed to
operate in this mode of operation. When Port A and Port B are programmed in Mode 1, six pins of Port
C are used for their control. PCo, PCl and PC2 are used for the control of the port B which can be used
either as input or output port. If the Port A is operated as an input PC3, PC4 and PCs are used for its
control. The remaining pins of Port C i.e. PC6 and PC7 can be used as either input or output. When
Port A is operated as an output port, pins PC3, and PC6 and PC7 are used for its control.
Mode 2 is strobed bidirectional mode of operation. In this mode Port A can be programmed to
operate as a bidirectional port. The Mode 2 operation is only for Port A. When Port A programmed in
Mode 2, the Port B can be used in either Mode 1 or Mode 0. For Mode 2 operation PC3 to PC7 are
Operating Modes
Strobed mode
Control Groups: For the control purpose 24 lines of I/O ports are divided into two groups, namely
Group A and Group B. The Group A contains the Port A and the Port C upper The Group B contains the
Port B and the Port Clower. A control word is formed which contains the information regarding the
function and modes of the ports. The CPU outputs the control word to 8255. The control word
initializes ports. The control blocks receive control words from internal data bus of 8255 and issue the
Control Groups
Group A Group B
Control Word: The bits of the control word are as shown in Fig. 7.15. control word is written into the
control word register which is within 8255. No read operation of the control word register is allowed.
If a particular port is to be made an input port, the bit corresponding to that port is set to 1. For making
port an output port, the corresponding bit for the port is set to 0. The detailed description the bits of the
Bit No.2. It is for the selection of the mode for the Port B. If the Port B has to operate in Mode
Bit No.5 These bits are to define the operating mode of the Port A. For the various
Mode 0 0 0
Mode 1 0 1
Mode 2 1 0 or 1
Bit No.7. It is set to 1 if ports A, B and C are defined as input/output ports. It is set to 0 if the
Example 1: Form control word for the following configuration of the ports of Intel 8255
Port A-output
Port B -output
Port Clower-output
Port Cupper-input
The control word bit for the above configuration of the ports are as shown in Fig. 7.17. The
control word for the above definition of the ports of Intel 8255 is 88 H.
7 6 5 4 3 2 1 0 Bit No.
1 0 0 0 1 0 0 0
8 8
Example 2: Make Control word for the following arrangement of the ports of Intel 8255
Port A-output
Port B -output
Port Clower-output
Port Cupper-output
The control word bit for the above configuration of the ports are as shown in Fig. 7.18. The
control word for the above definition of the ports of Intel 8255 is 80 H.
7 6 5 4 3 2 1 0 Bit No.
1 0 0 0 0 0 0 0
8 0
MICROPROCESSOR APPLICATIONS
5.1 Introduction
A microprocessor-based system being very small and compact forms a part of the equipment
logic. They have numerous applications such as measurement, display and control of current, voltage,
power factor, frequency, temperature, stress, strain, pressure, force, deflection, vibration, water level
etc. communication, transportation, traffic control, lift control, military equipment, robotics…
A delay program is used to provide the desired delay. To generate delay a few registers of the
microprocessor are loaded with desired numbers and then decremented to zero. The delay time
Program
Address Codes
FC06 C9 RET
To generate very small delay only one register can be used. In above program register B has
been loaded by 10H. then register B is decremented and program moves in a loop till the content of
register B becomes zero. After this program returns to the main program.
To calculate delay time is examined that how many times each instruction of the above
program is executed.
Instruction states
MVI B, 10 7
DCR B 4
JNZ 7/10
RET 10
The instruction JNZ takes 10 states when the content of register B is not zero and the program
jump to the label LOOP. JNZ takes only 7 states when the content of register B has become zero and
The instructions MVI B, l0H and RET are executed only once. The instruction DCR B is
executed 16 times. The instruction JNZ is executed 16 times, out of which 15 times the program jumps
to the label LOOP as the content of register B has not become zero, and takes 10 states each time. At
last the content of register B becomes zero, JNZ is executed and the program proceeds further. The last
Program
Instruction States
LXI D 10
DCX D 6
MOV A, D 4
ORA E 4
JNZ 7/10
RET 10
Program
Address Codes
2406 C2, 05, 24 JNZ LOOP II Is [C] zero? No, go to LOOP II yes
proceed further.
proceed further.
In the program registers Band C are loaded by the numbers 10H and 78H respectively. Then
these numbers are decremented to zero. To calculate the delay we have to examine that many times
each instruction of the program is executed. First of all the instruction MVI B, 10H is executed only
once and the register B is loaded by 10H. Then the next instruction MVI C, 78H is executed and the
register C is loaded by 78H. The instruction DCR C decrements register C by 1. Now the content of
The instruction JNZ examines whether the content of the register C has become zero. As the
content of the register C has become 77H; not zero, the program jumps to the label LOOP II. The
instruction DCR C again decrements register C by 1. The instruction JNZ in examines whether the
content of the register C has become zero. The program jumps to label LOOP II again. This process is
continued and the program moves in LOOP II till the content of register C becomes zero. In this way
the instruction DCR C and JNZ are executed 120 (78H) times to make the content of register C zero.
After this the program comes out of loop and moves further and executes the instruction DCR B. The
content of register B is decreased from 10H to 0F. The next instruction JNZ examines whether the
content of register B has become zero. As the content of register B is not zero. the program jumps to
The instruction MVI C, 78H is again executed and the register C is again loaded by number
78H. The instructions DCR C and JNZ LOOP II are again executed 120 times to make the content of
register C zero. After this the program comes out of LOOP II and the instruction DCR B is executed.
Now the content of register B is decreased from F to E. The instruction JNZ LOOP I is executed and
the program jumps to the label LOOP I again. The whole process of loading of register C , making its
content zero and decrementing of register B is repeated again and again till the content of register B
becomes zero. Thus we see that the program jumps (16-1) times to the label LOOP I as the content of
register B is 10H.
the instruction MVI C, 78 H is executed 16 times. The instruction DCR C and JNZ LOOP II
executed 120x16= 1920 times because for each decrement of register B, DCR C and JNZ LOOP II are
executed 120 times. The instruction JNZ LOOP I is executed 16 times out of which program jumps to
LOOP I (16-1)= 15 times as the content of register B has not become zero and JNZ LOOP I takes 10
states each time. At last when the content of register B becomes zero, JNZ is executed and the program
proceeds further. This time the execution of JNZ takes only 7 states. Similarly, JNZ LOOP II is
executed 120x16 times out of which (120-1)x16 program jumps to LOOP II, and JNZ LOOP II takes
10 states each time when the content register C is not zero. JNZ LOOP II is executed 16 times and
proceeds further taking only 7 states each time when the content of register C is zero.
Instruction states
MVI 7
DCR 4
JNZ 7/10
RET 10
Program
Address Codes
240E 0D DCR C
2412 05 DCR B
The numbers 50 in register B, FF in C and FF in D are moved to get the desired delay. The
delay time with these numbers is about 25 sec. this time has been noted by stop watch in laboratory.
The maximum delay with three register can be obtained when all registers are loaded with FF. the
The seven-segment LED display is a multiple display. It can display all decimal digits and
some letters. It is very popular among multiple displays as it has the smallest number of separately
controlled light emitting diodes (LED). Multiple displays of 9-segment LED, 14-segment LED and
In seven-segment displays there are seven light emitting diodes (LED) as shown in Fig. 9.2
Each LED can be controlled separately. To display a digit or letter the desired segments made ON as
There are two types of 7-segment displays namely, common-Cathode type and common-anode
type. In a common-cathode type display all the 7 cathodes of LEDs are tied together to the ground as
shown in Fig. 9.4 (a). When a +5 Vd.c is applied to any segment, the corresponding diode emits light.
Thus applying logic '1' i.e. positive logic to the desired segments, the desired letter or decimal number
can be displayed.
In common-anode type display all the 7 anodes are tied together and connected to + 5 V supply
as shown Fig. 9.4 (b). A particular segment will emit light when 0 logic is applied to it.
The seven-segment displays are not connected to I/O ports directly. They are connected
through buffers or drivers/decoders. 7446A, 74L46, 7447, 74L47 and 74LS47 are decoders/drivers for
common-anode type seven segment displays. 7448, 74LS48, 7449 and 74LS49 are decoders/drivers
for common-cathode type seven segment displays. Fig. 9.5 shows the pin configuration of 74LS48.
FND 500 and FND 503 are common cathode 7-segment displays. Fig 9.6 shows the pin
MAN 74 A:
MAN 74A is a common-cathode 7-segment display. The pin configuration of MAN 74A is
Fig. 9.8 shows the interfacing of decoders/drivers 74LS48 and 7-segment display MAN 74A with
microprocessor.
Table 9.1 is a functional table for 74LS48. the program to display the decimal number is as follows:
Address Codes
The control word 98 H makes the port B an output port, The Microprocessor outputs 05 at the
Port B. The pins PBo - PB3 of the port B are connected to decoder/driver 74LS48. Thus the binary bits
corresponding to the decimal number 5 are applied to 74LS48 and it is displayed by the 7-segment
display. 0 is the MSB of the decimal number 05. The logic for 0 is outputed on the pins PB4 - PB7.
These pins are not connected anywhere and consequently 0 is not displayed. If we use 2
decoder/drivers and 7-segment displays. shown in Fig. 9.9, No.1 display will display 5 and No.2
display will show 0. Thus two units of display will display 2 desired decimal numbers. Suppose we
want to display 89. For this purpose, in the above program the data of the memory location 2405 is
changed to 89. Now the microprocessor will output 89 at Port B and 1st unit will display 9 and the 2nd
unit 8.
To measure the frequency of a signal, the time period for half cycle is measured which is
inversely proportional to the frequency. A sinusoidal signal is converted to square wave using a
voltage comparator LM 311 or operational amplifier LM 747 or LM 324 as shown in Fig. 9.31. A
diode is used to rectify the output signal. A potential is used to reduce the magnitude to 5 volts.
A program has been developed to sense the zero instant of the rectified square wave.
microprocessor measures the magnitude of the square wave at two consecutive points as shown in Fig.
9.32. The two magnitudes are compared and decision is taken on the basis of carry and zero status
Various points have been shown in Fig. 9.32. Very near to P3 at its left side the magnitude of
square wave is zero, and at P4, 5V, at logic ’1’. The microprocessor subtracts the 1st value from the
2nd, so the result is non-zero and there is no carry. This is the basis for the selection of zero instant
point. Suppose the microprocessor takes reading at P1 and P2 where both magnitudes are zero.
Difference of the two is zero. So this is not the zero instant of the wave. At points P5, and P6, the
difference of the two values is zero, so it is also not a zero instant point. P7 and p8, the difference is
non-zero but there is carry. So it is the end point of the half-square wave.
The microprocessor reads the magnitude of the square wave again and again, and moves in the
loop. It crosses the loop when the magnitude of the square wave becomes zero. Thus the time for half
cycle is measured. The count can be compared with the stored numbers in a look-up table and the
frequency can be displayed. The count which is inversely proportional to the frequency of the input
signal can be used for further processing and control as desired. An interfacing circuitry is shown in
Fig. 9.33.
Program:
Address Codes
2006 47 MOV B, A
2010 01, 00, 00 LXI B, 00, 00 Initialize B-C pair for counting
2016 1F RAR
No, go to LOOP
In the above program the part of the program from the memory address 2004 to 200F is detect the
zero instant of the square wave. IN 00 at the memory location 2004 is the 1st reading of the magnitude
of the square wave. MOV B, A transfers the 1st reading from the accumulator to the register B. Again
IN 00 at the memory address 2007 takes the 2nd reading of the magnitude. CMP B compares these two
readings. JZ indicates the condition that both readings are of equal magnitudes, i.e. readings are either
0, 0 or 1, 1. Therefore, it is not a condition of zero instant and the program jumps to the label BACK.
JC indicates that the 1st reading is 1 and the 2nd reading is 0. This is the condition for the end of
So, program again jumps to the label BACK. The program will move further only when the result
is non-zero and there is no carry. This will be the case when the 1st reading is 0 and the 2 nd reading is
1. This is the case of zero instant. Once the zero instant is detected the program move in a loop till the
square wave exists. Thus the time period for half cycle is measured. The count is inversely
proportional to the frequency. The count can be used for further processing control. If frequency is to
be displayed 7-segment displays can be interfaced and using look-up table technique it can be
displayed. The program given above is only for the frequency measurement.
For the measurement of temperature one of the following devices are used:
Platinum wires are frequently used in resistance thermometers for industrial applications because
of greater resolution, and mechanical and electrical stability as compared to copper or nickel wire. A
change in temperature causes a change in resistance. The resistance thermometer is placed in an arm of
A thermistor is a semiconductor device fabricated from a sintered mixture of metal alloys, having
a large negative temperature coefficient. A thermistor is used in a Wheatstone bridge to get a voltage
proportional to temperature. It can be used in range of -100 to + 100 0 C for greater accuracy as
Chromel-constantan 0 to 1200
Pt-Rh-Platinum 0 to 1500
Tungsten-rhenium 0 to 2000
Microprocessor-Based Scheme.
Fig. 9.40 (a) shows a microprocessor-based scheme for temperature measurement and control.
The output of a thermocouple proportional to the temperature of the furnace or oven etc. is in millivolt.
It is to be amplified using multistage amplifier The amplified voltage is applied to an A/D converter.
The microprocessor displays the measured temperature. If the temperature of a furnace, oven
or water-bath is to be controlled, the microprocessor first measures its temperature, and then compares
the measured temperature with a reference temperature at which the temperature is to be maintained. If
the measured temperature is higher than the reference temperature, microprocessor sends control
signal to reduce temperature. if the measured temperature is less than the reference temperature, the
microprocessor sends a control signal to increase temperature The temperature of a furnace or oven
can be increased or decreased by increasing or decreasing the fuel input to the furnace. If heating is
done by electric heaters, current in heating element is controlled. Fig. 9.40 (b) shows an amplifier
circuit to amplify the output of the thermocouple. D.C. level detector is for initial adjustment.
Program:
Address Codes
Result:
In 0C millivolts volts
45 0.3 0.66 2D
Department of Computer Science, Thanthai Hans Roever College, Perambalur
Microprocessor and It’s Applications 177
50 0.5 0.95 38
55 0.8 1.29 44
60 0.9 1.56 51
65 1.2 2.03 62
70 1.4 2.19 70
75 1.5 2.49 7F
80 1.7 2.69 8B
85 2.0 3.05 9E
90 2.2 3.33 AA
95 2.5 3.72 C1
A microprocessor-based water level indicator can be developed as shown in fig. 9.49. the
water tank is at ground potential. Probes are connected to 5 V d.c through resisters. When a probe is
immersed in water it is at ground potential and its logic is 0. when it is not immersed in water, it is at
5V potential and logic is 1. these probes are connected to an inverter which inverts the logic of probes.
After inversion the probe which is not immersed in water gives 0 logic and the probe immersed in
water output logic 1. the output of inverter are connected to port A of 8255. in the interface only six
probes have been used. The 6 output points of the inverter are connected to 5 pins of Port A. the
remaining 2 pins of Port A are grounded. The 2 nd unit of 8255, i.e. 8255.2 has been used for this
purpose.
The microprocessor reads the binary logic corresponding to water level from the port, and
displays it on 7-segment display which are connected to Port B. the values of water levels at which
probes are placed in the tank are stored in memory in the form of look-up table.
The microprocessor counts how many probes are immersed in water and determines the LSB of
the memory address of look-up table. Suppose 1st, 2nd and 3rd probes are immersed in water. These
probes are at logic 1. the microprocessor counts that 3 probes are immersed in water and it picks up the
Automatic Pumping:
Automatic pumping can be done on the basis of water level in the tank. The program given
below has been developed to switch on a pump when water level is 20cm or less than 20 cm. the pump
Address Codes
FC10 04 INR B
FC16 7E MOV A, M
DELAY SUBROUTINE
Address Codes
FC4A 0D DCR C
FC4E 05 DCR B
FC52 C9 RET
Data
FD00 - 00
FD01 - 10
FD02 - 20
FD03 - 30
FD04 - 40
FD05 - 50
FD06 - 60
Fig. 9.54 shows a simple arrangement and port connections for microprocessor-based traffic
control. All ports of 8255 have been programmed as output ports. The control word to make all ports
The connection of pins of the ports to LED have been made through buffers (7407). Positive
logic has been used to switch on LEDs. Three types of LEDs have been used red, yellow and green.
Green light glows to allow crossing, yellow to make alert, and red does not allow crossing.
Green light for right turns have not been shown. One can add some more LEDs for this
Address Codes
DELAY 1
FD0A 0D DCR C
FD0E 05 DCR B
FD12 C9 RET
DELAY I1