Introduction to microcomputer and Microprocessor
Computer's Central Processing Unit (CPU) built on a single Integrated Circuit (IC) is called
a microprocessor.
A digital computer with one microprocessor which acts as a CPU is called microcomputer.
It is a programmable, multipurpose, clock -driven, register-based electronic device that reads
binary instructions from a storage device called memory, accepts binary data as input and
processes data according to those instructions and provides results as output.
The microprocessor contains millions of tiny components like transistors, registers, and diodes
that work together.
Block Diagram of a Microcomputer
A microprocessor consists of an ALU, control unit and register array. Where ALU performs
arithmetic and logical operations on the data received from an input device or memory. Control
unit controls the instructions and flow of data within the computer. And, register array consists
of registers identified by letters like B, C, D, E, H, L, and accumulator.
Basic Terms used in Microprocessor
Here is a list of some basic terms used in microprocessor:
Instruction Set - The group of commands that the microprocessor can understand is called
Instruction set. It is an interface between hardware and software.
Bus - Set of conductors intended to transmit data, address or control information to different
elements in a microprocessor. A microprocessor will have three types of buses, i.e., data bus,
address bus, and control bus.
IPC (Instructions Per Cycle) - It is a measure of how many instructions a CPU is capable of
executing in a single clock.
Clock Speed - It is the number of operations per second the processor can perform. It can be
expressed in megahertz (MHz) or gigahertz (GHz). It is also called the Clock Rate.
Bandwidth - The number of bits processed in a single instruction is called Bandwidth.
Working of Microprocessor
The microprocessor follows a sequence to execute the instruction: Fetch, Decode, and then
Execute.
Initially, the instructions are stored in the storage memory of the computer in sequential order.
The microprocessor fetches those instructions from the stored area (memory), then decodes it
and executes those instructions till STOP instruction is met. Then, it sends the result in binary
form to the output port. Between these processes, the register stores the temporary data and ALU
(Arithmetic and Logic Unit) performs the computing functions.
Timing and control unit
It provides timing and control signal to the microprocessor to perform operations. Following are
the timing and control signals, which control external and internal circuits −
Control Signals: READY, RD’, WR’, ALE
Status Signals: S0, S1, IO/M’
DMA Signals: HOLD, HLDA
RESET Signals: RESET IN, RESET OUT
8085 Architecture
Microprocessor - 8085 Pin Configuration
Address bus
A15-A8, it carries the most significant 8-bits of memory/IO address.
Data bus
AD7-AD0, it carries the least significant 8-bit address and data bus.
Control and status signals
These signals are used to identify the nature of operation. There are
3 control signal and 3 status signals.
Three control signals are RD, WR & ALE.
RD − This signal indicates that the selected IO or memory
device is to be read and is ready for accepting data available
on the data bus.
WR − This signal indicates that the data on the data bus is to
be written into a selected memory or IO location.
ALE − It is a positive going pulse generated when a new
operation is started by the microprocessor. When the pulse
goes high, it indicates address. When the pulse goes down it
indicates data.
Three status signals are IO/M, S0 & S1.
IO/M
This signal is used to differentiate between IO and Memory
operations, i.e. when it is high indicates IO operation and when it is
low then it indicates memory operation.
S1 & S0
These signals are used to identify the type of current operation.
Power supply
There are 2 power supply signals − VCC & VSS. VCC indicates +5v
power supply and VSS indicates ground signal.
Clock signals
There are 3 clock signals, i.e. X1, X2, CLK OUT.
X1, X2 − A crystal (RC, LC N/W) is connected at these two pins
and is used to set frequency of the internal clock generator.
This frequency is internally divided by 2.
CLK OUT − This signal is used as the system clock for devices
connected with the microprocessor.
Interrupts & externally initiated signals
Interrupts are the signals generated by external devices to request
the microprocessor to perform a task. There are 5 interrupt signals,
i.e. TRAP, RST 7.5, RST 6.5, RST 5.5, and INTR.
INTA − It is an interrupt acknowledgment signal.
RESET IN − This signal is used to reset the microprocessor by
setting the program counter to zero.
RESET OUT − This signal is used to reset all the connected
devices when the microprocessor is reset.
READY − This signal indicates that the device is ready to send
or receive data. If READY is low, then the CPU has to wait for
READY to go high.
HOLD − This signal indicates that another master is requesting
the use of the address and data buses.
HLDA (HOLD Acknowledge) − It indicates that the CPU has
received the HOLD request and it will relinquish the bus in the
next clock cycle. HLDA is set to low after the HOLD signal is
removed.
Serial I/O signals
There are 2 serial signals, i.e. SID and SOD and these signals are
used for serial communication.
SOD (Serial output data line) − The output SOD is set/reset as
specified by the instruction.
SID (Serial input data line) − The data on this line is loaded
into accumulator whenever a instruction is executed.
Registers of 8085 microprocessor
A microprocessor is a multipurpose, programmable, clock-driven, register-
based electronic device that reads binary instructions from a storage device
called memory, accepts binary data as input and processes data according to
those instructions and provide results as output. A 8085 microprocessor, is a
second generation 8-bit microprocessor and is the base for studying and using all
the microprocessor available in the market.
Registers in 8085:
(a) General Purpose Registers – The 8085 has six general-purpose
registers to store 8-bit data; these are identified as- B, C, D, E, H,
and L. These can be combined as register pairs – BC, DE, and HL,
to perform some 16-bit operation. These registers are used to
store or copy temporary data, by using instructions, during the
execution of the program.
(b) Specific Purpose Registers –
Accumulator: The accumulator is an 8-bit register (can store 8-bit
data) that is the part of the arithmetic and logical unit (ALU). After
performing arithmetical or logical operations, the result is stored in
accumulator. Accumulator is also defined as register A.
Flag registers:
The flag register is a special purpose register and it is completely
different from other registers in microprocessor. It consists of 8 bits and
only 5 of them are useful. The other three are left vacant and are used in
the future Intel versions. These 5 flags are set or reset (when value of
flag is 1, then it is said to be set and when value is 0, then it is said to be
reset) after an operation according to data condition of the result in the
accumulator and other registers.
1. Sign Flag: It occupies the seventh bit of the flag register, which is also
known as the most significant bit. It helps the programmer to know
whether the number stored in the accumulator is positive or negative.
If the sign flag is set, it means that number stored in the accumulator
is negative, and if reset, then the number is positive.
2. Zero Flag:: It occupies the sixth bit of the flag register. It is set, when
the operation performed in the ALU results in zero(all 8 bits are zero),
otherwise it is reset. It helps in determining if two numbers are equal
or not.
3. Auxiliary Carry Flag: It occupies the fourth bit of the flag register. In
an arithmetic operation, when a carry flag is generated by the third bit
and passed on to the fourth bit, then Auxiliary Carry flag is set. If not
flag is reset. This flag is used internally for BCD(Binary-Coded decimal
Number) operations.
4. Parity Flag: It occupies the second bit of the flag register. This flag
tests for number of 1’s in the accumulator. If the accumulator holds
even number of 1’s, then this flag is set and it is said to even parity.
On the other hand if the number of 1’s is odd, then it is reset and it is
said to be odd parity.
5. Carry Flag: It occupies the zeroth bit of the flag register. If the
arithmetic operation results in a carry(if result is more than 8 bit), then
Carry Flag is set; otherwise it is reset.
Program Counter: This register is used to sequence the execution of the
instructions. The function of the program counter is to point to the
memory address from which the next byte is to be fetched. When a byte
(machine code) is being fetched, the program counter is incremented by
one to point to the next memory location.
Stack Pointer: It is used as a memory pointer. It points to a memory
location in read/write memory, called the stack. It is always
incremented/decremented by 2 during push and pop operation.
Uses of Registers of 8085 microprocessor :
Here are some common uses of the different registers in the 8085
microprocessor:
1. Accumulator (A) register: The accumulator register is the most
commonly used register in the 8085 microprocessor. It is used for
arithmetic and logical operations, as well as for input/output (I/O)
operations. The accumulator is also used as a temporary storage
location for data.
2. Program Counter (PC) register: The PC register is used to keep
track of the memory location of the current instruction. When an
instruction is executed, the PC register is automatically incremented to
point to the next instruction in memory.
3. Stack Pointer (SP) register: The SP register is used to keep track of
the top of the stack. The stack is used for temporary storage of data
and return addresses during subroutine calls.
4. Flag Register: The flag register is used to store status information
about the results of arithmetic and logical operations, including
whether a result is negative, zero, or carry.
5. General Purpose Registers (B, C, D, E, H, and L): These registers
are used for general purpose storage of data, as well as for
addressing memory locations. They can be used in pairs as 16-bit
registers, such as BC, DE, and HL, for more efficient addressing of
memory locations.
6. Instruction Register (IR) and Machine Cycle Register (MCR): These
registers are used internally by the microprocessor to decode
instructions and control the timing of machine cycles.
Microprocessor - 8085 Instruction Sets
The various techniques to specify data for instructions are:
1. 8-bit or 16-bit data may be directly given in the instruction itself.
2. The address of the memory location, I/O port or I/O device, where data
resides, may be given in the instruction itself.
3. In some instructions, only one register is specified. The content of the
specified register is one of the operands.
4. Some instructions specify two registers. The contents of the registers are
the required data.
5. In some instructions, data is implied. The most instructions of this type
operate on the content of the accumulator.
Due to different ways of specifying data for instructions, the machine codes of
all instructions are not of the same length. It may 1-byte, 2-byte or 3-byte
instruction.
Arithmetic Group
The instructions of this group perform arithmetic operations such as addition,
subtraction, increment or decrement of the content of a register or a memory.
Opcode Operand Meaning Explanation
The contents of the
register or memory
Add register are added to the
R or memory, to contents of the
ADD
M the accumulator and the
accumulator result is stored in
the accumulator.
Example − ADD K.
The contents of the
register or memory
Add register
& M the Carry flag
R to the
ADC are added to the
M accumulator
contents of the
with carry
accumulator and the
result is stored in
the accumulator.
Example − ADC K
The 8-bit data is
added to the
Add the
contents of the
immediate to
ADI 8-bit data accumulator and the
the
result is stored in
accumulator
the accumulator.
Example − ADI 55K
The 8-bit data and
the Carry flag are
Add the
added to the
immediate to
contents of the
ACI 8-bit data the
accumulator and the
accumulator
result is stored in
with carry
the accumulator.
Example − ACI 55K
The instruction
stores 16-bit data
Load the into the register pair
LXI Reg. pair, 16bit data register pair designated in the
immediate operand.
Example − LXI K,
3025M
The 16-bit data of
Add the the specified register
register pair pair are added to
DAD Reg. pair
to H and L the contents of the
registers HL register.
Example − DAD K
Subtract the The contents of the
R register or the register or the
SUB
M memory from memory are
the subtracted from the
accumulator contents of the
accumulator, and
the result is stored
in the accumulator.
Example − SUB K
The contents of the
register or the
memory & M the
Subtract the
Borrow flag are
source and
R subtracted from the
SBB borrow from
M contents of the
the
accumulator and the
accumulator
result is placed in
the accumulator.
Example − SBB K
The 8-bit data is
subtracted from the
Subtract the
contents of the
immediate
SUI 8-bit data accumulator & the
from the
result is stored in
accumulator
the accumulator.
Example − SUI 55K
Data-transfer Instructions
Opcode Operand Meaning Explanation
This instruction
copies the
contents of the
Copy from the
Rd, Sc source register
source (Sc) to
MOV M, Sc into the
the
Dt, M destination
destination(Dt)
register without
any alteration.
Example − MOV K,
L
The 8-bit data is
stored in the
destination
Rd, data Move
MVI register or
M, data immediate 8-bit
memory.
Example − MVI K,
55L
The contents of a
memory location,
specified by a 16-
bit address in the
Load the
LDA 16-bit address operand, are
accumulator
copied to the
accumulator.
Example − LDA
2034K
The contents of
the designated
register pair point
to a memory
Load the location. This
LDAX B/D Reg. pair accumulator instruction copies
indirect the contents of
that memory
location into the
accumulator.
Example − LDAX K
The instruction
loads 16-bit data
Load the in the register pair
LXI Reg. pair, 16-bit data register pair designated in the
immediate register or the
memory.
Example − LXI K,
3225L
The instruction
copies the
contents of the
memory location
pointed out by the
address into
Load H and L register L and
LHLD 16-bit address
registers direct copies the
contents of the
next memory
location into
register H.
Example − LHLD
3225K
The contents of
the accumulator
are copied into
the memory
location specified
by the operand.
This is a 3-byte
instruction, the
STA 16-bit address 16-bit address
second byte
specifies the low-
order address and
the third byte
specifies the high-
order address.
Example − STA
325K
The contents of
Store the the accumulator
STAX 16-bit address accumulator are copied into
indirect the memory
location specified
by the contents of
the operand.
Example − STAX K
8085 Branching Instructions
Opcode Operand Meaning Explanation
The program
Jump sequence is
16-bit
JMP unconditio transferred to the
address
nally memory address
given in the operand.
Flag
Opcode Description
Status
JC Jump on Carry CY=1
Jump on no
JNC CY=0
Carry
Jump on The program
JP S=0 sequence is
positive
Jump transferred to the
16-bit
JM Jump on minus S=1 conditional memory address
address
ly given in the operand
JZ Jump on zero Z=1 based on the specified
flag of the PSW.
Jump on no
JNZ Z=0
zero
Jump on parity
JPE P=1
even
Jump on parity
JPO P=0
odd
Unconditio The program
Flag 16-bit
Opcode Description nal sequence is
Status address
subroutine transferred to the
CC Call on Carry CY=1 call memory address
given in the operand.
Call on no Before transferring,
CNC CY=0 the address of the
Carry
next instruction after
CP Call on positive S=0 CALL is pushed onto
the stack.
CM Call on minus S=1
CZ Call on zero Z=1
CNZ Call on no zero Z=0
Call on parity
CPE P=1
even
Call on parity
CPO P=0
odd
Return The program
from sequence is
RET None subroutine transferred from the
unconditio subroutine to the
nally calling program.
Flag
Opcode Description
Status
RC Return on Carry CY=1
The program
Return on no sequence is
RNC CY=0 transferred from the
Carry Return
subroutine to the
from
Return on calling program based
RP S=0 None subroutine
positive on the specified flag of
conditional
the PSW and the
ly
RM
Return on
S=1 program execution
minus begins at the new
address.
RZ Return on zero Z=1
Return on no
RNZ Z=0
zero
Return on parity
RPE P=1
even
Return on parity
RPO P=0
odd
8085 Logical Instructions
Opcode Operand Meaning Explanation
Compare the The contents of the operand
R register or (register or memory) are M
CMP
M memory with compared with the contents
the accumulator of the accumulator.
Compare The second byte data is
CPI 8-bit data immediate with compared with the contents
the accumulator of the accumulator.
The contents of the
Logical AND accumulator are logically
R register or AND with M the contents of
ANA
M memory with the register or memory, and
the accumulator the result is placed in the
accumulator.
The contents of the
Logical AND accumulator are logically
ANI 8-bit data immediate with AND with the 8-bit data and
the accumulator the result is placed in the
accumulator.
The contents of the
Exclusive OR
accumulator are Exclusive OR
R register or
XRA with M the contents of the
M memory with
register or memory, and the
the accumulator
result is placed in the
accumulator.
The contents of the
Exclusive OR accumulator are Exclusive OR
XRI 8-bit data immediate with with the 8-bit data and the
the accumulator result is placed in the
accumulator.
The contents of the
Logical OR accumulator are logically OR
R register or with M the contents of the
ORA
M memory with register or memory, and
the accumulator result is placed in the
accumulator.
The contents of the
Logical OR accumulator are logically OR
ORI 8-bit data immediate with with the 8-bit data and the
the accumulator result is placed in the
accumulator.
Each binary bit of the
accumulator is rotated left by
Rotate the one position. Bit D7 is placed
RLC None
accumulator left in the position of D0 as well
as in the Carry flag. CY is
modified according to bit D7.
Each binary bit of the
accumulator is rotated right
Rotate the by one position. Bit D0 is
RRC None accumulator placed in the position of D7
right as well as in the Carry flag.
CY is modified according to
bit D0.
Addressing modes of 8085
Using mnemonics without any alteration in the content, data can be
transferred in three different cases –
From one register to another register
From the memory to the register and
From the register to the memory
These can be guided by addressing modes. Addressing modes in 8085
can be classified into 5 groups −
Immediate addressing mode
Register addressing mode
Direct addressing mode
Indirect addressing mode
Implied addressing mode
1. Immediate Addressing Mode –
In immediate addressing mode the source operand is always data. If
the data is 8-bit, then the instruction will be of 2 bytes, if the data is of
16-bit then the instruction will be of 3 bytes.
Examples:
MVI B 45 (move the data 45H immediately to register B)
LXI H 3050 (load the H-L pair with the operand 3050H immediately)
JMP address (jump to the operand address immediately)
2. Register Addressing Mode –
In register addressing mode, the data to be operated is available
inside the register(s) and register(s) is(are) operands. Therefore the
operation is performed within various registers of the microprocessor.
Examples:
MOV A, B (move the contents of register B to register A)
ADD B (add contents of registers A and B and store the result in
register A)
INR A (increment the contents of register A by one)
3. Direct Addressing Mode –
In direct addressing mode, the data to be operated is available inside
a memory location and that memory location is directly specified as an
operand. The operand is directly available in the instruction itself.
Examples:
LDA 2050 (load the contents of memory location into accumulator A)
LHLD address (load contents of 16-bit memory location into H-L
register pair)
IN 35 (read the data from port whose address is 35)
4. Register Indirect Addressing Mode –
In register indirect addressing mode, the data to be operated is
available inside a memory location and that memory location is
indirectly specified by a register pair.
Examples:
MOV A, M (move the contents of the memory location pointed by the
H-L pair to the accumulator)
LDAX B (move contents of B-C register to the accumulator)
STAX B (store accumulator contents in memory pointed by register
pair B-C)
5. Implied/Implicit Addressing Mode –
In implied/implicit addressing mode the operand is hidden and the
data to be operated is available in the instruction itself.
Examples:
CMA (finds and stores the 1’s complement of the contents of
accumulator A in A)
RRC (rotate accumulator A right by one bit)
RLC (rotate accumulator A left by one bit)
8255 PPI(Programmable Peripheral Interface):
The 8255A is a general purpose programmable I/O device designed
to transfer the data from I/O to interrupt I/O under certain
conditions as required. It can be used with almost any
microprocessor.
It consists of three 8-bit bidirectional I/O ports (24I/O lines) which
can be configured as per the requirement.
Ports of 8255A
8255A has three ports, i.e., PORT A, PORT B, and PORT C.
Port A contains one 8-bit output latch/buffer and one 8-bit
input buffer.
Port B is similar to PORT A.
Port C can be split into two parts, i.e. PORT C lower (PC0-PC3)
and PORT C upper (PC7-PC4) by the control word.
These three ports are further divided into two groups, i.e. Group A
includes PORT A and upper PORT C. Group B includes PORT B and
lower PORT C. These two groups can be programmed in three
different modes, i.e. the first mode is named as mode 0, the second
mode is named as Mode 1 and the third mode is named as Mode 2.
Operating Modes
8255A has three different operating modes −
Mode 0 − In this mode, Port A and B is used as two 8-bit ports
and Port C as two 4-bit ports. Each port can be programmed in
either input mode or output mode where outputs are latched
and inputs are not latched. Ports do not have interrupt
capability.
Mode 1 − In this mode, Port A and B is used as 8-bit I/O ports.
They can be configured as either input or output ports. Each
port uses three lines from port C as handshake signals. Inputs
and outputs are latched.
Mode 2 − In this mode, Port A can be configured as the
bidirectional port and Port B either in Mode 0 or Mode 1. Port A
uses five signals from Port C as handshake signals for data
transfer. The remaining three signals from Port C can be used
either as simple I/O or as handshake for port B.
8255 Architecture
The following figure shows the architecture of 8255A −
CS’ A1 A0 Selection
0 0 0 PORT A
0 0 1 PORT B
CS’ A1 A0 Selection
0 1 0 PORT C
0 1 1 Control Register
1 X X No Seletion
Timing diagram of MOV Instruction in
Microprocessor:
The timing diagram is a graphical representation of the process in steps
with respect to time. It represents the step by step working of each
instruction and its execution. The execution time of instructions is
represented in T-states.
Problem – Draw the timing diagram of the given instruction in 8085,
MOV B, C
Given instruction copy the contents of the source register into the
destination register and the contents of the source register are not
altered.
Example:
MOV B, C
Opcode: MOV
Operand: B and C
Bis is the destination register and C is the source register whose contents
need to be transferred to the destination register. Algorithm – The
instruction MOV B, C is of 1 byte; therefore the complete instruction will
be stored in a single memory address. For example:
Only opcode fetching is required for this instruction and thus we need 4 T
states for the timing diagram. For the opcode fetch the IO/M (low active)
= 0, S1 = 1 and S0 = 1. The timing diagram of MOV instruction is shown
below:
In Opcode fetch ( t1-t4 T states):
8255 with A/D and D/A converter and their interfacing to the
microprocessor:
The Intel 8255 is a popular programmable peripheral interface (PPI)
chip designed for use with microprocessors. It has three 8-bit ports
(Port A, Port B, and Port C), which can be individually programmed
as input or output. The 8255 can be configured in various modes,
including Mode 0 (basic I/O), Mode 1 (bit set/reset), Mode 2 (strobe
handshaking), and Mode 3 (bidirectional bus).
However, the Intel 8255 itself does not have built-in analog-to-
digital (A/D) or digital-to-analog (D/A) converter functionality. If we
need analog-to-digital or digital-to-analog conversion, we would
typically need additional components.
To interface with analog signals, you might use an external A/D
converter (ADC) for converting analog signals to digital and a
digital-to-analog converter (DAC) for converting digital signals back
to analog.
Here's a general overview of how you might use an ADC and a DAC
in conjunction with an 8255 for analog interfacing:
Analog-to-Digital Conversion (ADC):
1.Connect the analog signal source to an external ADC.
2.Use the 8255's Port A or Port C(upper) as control lines to select
different channels on the ADC.
3.Read the digital output from the ADC using the data lines of the
8255.
Digital-to-Analog Conversion (DAC):
1.Write digital data to the 8255's Port C(lower).
2.Connect the output of the 8255 to the digital input of an external
DAC.
3. Connect the analog output of the DAC to the desired destination.
Stepper motor Interfacing/Control using 8085
Stepper Motor A stepper motor is a device that translates electrical
pulses into mechanical movement in steps of fixed step angle.
The stepper motor rotates in steps in response to the applied
signals.
It is mainly used for position control.
It is used in disk drives, dot matrix printers, plotters and robotics
and process control circuits.
The motor is controlled by ON/OFF the control winding.
• The popular stepper motor used for demonstration in
laboratories has a 200 steps per revolution.
• This motor consists of four stator winding and require four
switching sequence
Interfacing
Even a small stepper motor require a current of 400 mA for its
operation. But the ports of the microcontroller cannot source this
much amount of current. If such a motor is directly connected to
the microprocessor/microcontroller ports, the motor may draw large
current from the ports and damage it. So a suitable driver circuit is
used with the microprocessor/microcontroller to operate the motor.
Interfacing 7(Seven) Segment Display to 8085
Microprocessor
A seven-segment LED is a kind of LED(Light Emitting Diode)
consisting of 7 small LEDs it usually comes with the
microprocessor’s as we commonly need to interface them with
microprocessors like 8085.
Structure of Seven Segments LED :
The LED in Seven Segment display are arranged as below
It can be used to represent numbers from 0 to 8 with a decimal
point.
We have eight segments in a Seven Segment LED display
consisting of 7 segments which include ‘.’.
The seven segments are denoted as “a, b, c, d, e, f, g, h”
respectively, and ‘.’ is represented by “h”