8085 Microprocessor
8085 Microprocessor
8085 Microprocessor
ALU
The Arithmetic and Logic Unit, ALU performs the arithmetic and logical operations:
Addition
Subtraction
Logical AND
Logical OR
Logical EXCLUSIVE OR
Increment (add 1)
Decrement (subtract 1)
Clear, etc.
It is used to generate timing and control signals which are necessary for the execution
of instructions.
It is used to control data flow between CPU and peripherals (including memory).
It is used to provide status, control and timing signals which are required for the
operation of memory and I/O devices.
It is used to control the entire operations of the microprocessor and peripherals
connected to it.
Thus we can see that the control unit of the CPU acts as the brain of the computer system.
Registers
Registers are used for temporary storage and manipulation of data and instructions by the
microprocessor. Data remain in the registers till they are sent to the I/O devices or memory.
Intel 8085 microprocessor has the following registers:
Instruction register
Temporary register
In addition to the above mentioned registers the 8085 microprocessor contains a set of five
flip-flops which serve as flags (or status flags).
A flag is a flip-flop which indicates some conditions which arises after the execution of an
arithmetic or logical instruction.
1.Accumulator (ACC): The accumulator is an 8-bit register associated with the ALU.
The register 'A' is an accumulator in the 8085. It is used to hold one of the operands of
an arithmetic and logical operation.
The final result of an arithmetic or logical operation is also placed in the accumulator.
3.Program Counter (PC): It is a 16-bit special purpose register. It is used to hold the
address of memory of the next instruction to be executed. It keeps the track of the
instruction in a program while they are being executed.
The microprocessor increments the content of the next program counter during the
execution of an instruction so that at the end of the execution of an instruction it points
to the next instruction?s address in the program.
4.Stack Pointer (SP): It is a 16-bit special function register used as memory pointer. A
stack is nothing but a portion of RAM. In the stack, the contents of only those registers
are saved, which are needed in the later part of the program.
The stack pointer (SP) controls the addressing of the stack. The Stack Pointer contains
the address of the top element of data stored in the stack.
5.Instruction Register: The instruction register holds the opcode (operation code or
instruction code) of the instruction which is being decoded and executed.
6.Temporary Register: It is an 8-bit register associated with the ALU. It holds data
during an arithmetic/logical operation. It is used by the microprocessor. It is not
accessible to programmer.
7.Flags: The Intel 8085 microprocessor contains five flip-flops to serve as a status flags.
The flip-flops are reset or set according to the conditions which arise during an
arithmetic or logical operation.
The five status flags of Intel 8085 are:
Zero Flag(Z)
Sign Flag(S)
If a flip-flop for a particular flag is set, then it indicates 1. When it is reset, it indicates 0.
The Intel 8085 requires an address bus of 16-bit wide as the memory addresses 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 data/address bus, AD-bus
(pins AD0 ? AD7).
Pin Configuration
A8 ? A15 (Output): These are address bus and are used for the most significant bits
of the memory address or 8-bits of I/O address.
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 cycle. Again they are used for data during 2nd and 3rd
clock cycles.
Control and Status Signals
ALE (Output): ALE stands for Address Latch Enable signal. ALE 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 device.
S0, S1 (Output): These are status signals sent by the microprocessors to distinguish
the various types of operation given in table below:
RD (Output): RD is a signal to control READ operation. When it goes low, the selected I/O
device or memory is read.
WR (Output): WR is a signal to control WRITE operation. When it goes low, the
data bus' data is written into the selected memory or I/O location.
HOLD (INPUT): HOLD indicates that another device is requesting for the use of the
address and data bus.
HLDA (OUTPUT): HLDA is a signal for HOLD acknowledgement which indicates that
the HOLD request has been received. After the removal of this request the HLDA goes
low.
INTR (Input): INTR is an Interrupt Request Signal. Among interrupts it has the
lowest priority. The INTR is enabled or disabled by software.
RST 5.5, 6.5, 7.5 and TRAP (Inputs): These all are interrupts. When any interrupt is
recognized the next instruction is executed from a fixed location in the memory as
given below:
RST 7.5, RST 6.5 and RST 5.5 are the restart interrupts which cause an internal restart to be
automatically inserted.
The TRAP has the highest priority among interrupts. The order of priority of interrupts is as
follows:
RST 7.5
RST 6.5
RST 5.5
RESET OUT (Output): RESET OUT indicates that the CPU is being reset.
Clock Signals
CLK (Output): CLK is a clock output for user, which can be used for other digital ICs.
Its frequency is same at which processor operates.
Serial I/O Signals
SID (Input): SID is data line for serial input. The data on this line is loaded into the
seventh bit of the accumulator when RIM instruction is executed.
SOD (Output): SOD is a data line for serial output. The seventh bit of the
accumulator is output on SOD line when SIM instruction is executed.
Power Supply
8085 Instructions
An instruction of computer is a command given to the computer to perform a specified
operation on given data. Some instructions of Intel 8085 microprocessor are: MOV, MVI, LDA,
STA, ADD, SUB, RAL, INR, MVI, etc.
The 1st part of an instruction which specifies the task to be performed by the computer is
called Opcode.
The 2nd part of the instruction is the data to be operated on, and it is called Operand. The
Operand (or data) given in the instruction may be in various forms such as 8-bit or 16-bit
data, 8-bit or 16-bit address, internal registers or a register or memory location.
According to the word size, the Intel 8085 instructions are classified into the following
three types:
2. Two-byte instruction: In a two byte instruction the first byte of the instruction is its
opcode and the second byte is either data or address.
Example:
The first byte 06 is the opcode for MVI B and second byte 05 is the data which is to be moved
to register B.
3. Three-byte instruction: The first byte of the instruction is its opcode and the second and
third bytes are either 16-bit data or 16-bit address.
Example:
Instruction Cycle
The time required to fetch an instruction and necessary data from memory and to execute it,
is called an instruction cycle. Or the total time required to execute an instruction is given by:
IC = FC + EC
Where,
IC = Instruction Cycle
FC = Fetch Cycle
EC = Execute Cycle
Fetch the instruction (Fetch Cycle)
In the beginning of the fetch cycle, the content of the program counter (PC), which is the
address of the memory location where opcode is available, is sent to the memory. The
memory puts the opcode on the data bus so as to transfer it to the CPU.
The whole operation of fetching an opcode takes three clock cycles. A slow memory may take
more time.
If the operand is reside the general purpose registers, execution is immediately performed.
The time taken in decoding and execution of an instruction is one clock cycle.
In some situations, an execute cycle may involve one or more read or write cycles or both.
Read Cycle: If an instruction contains data or operand address which are in the memory, the
CPU has to perform some read operations to get the desired data. In case of a read cycle the
instruction received from the memory are data or operand address instead of an opcode.
Write Cycle: In write cycle data are sent from the CPU to the memory or an output device.
One sub-division of an operation performed in one clock cycle is called a state or T-state. In
short, one clock cycle of the system clock is referred to as a state.
Timing Diagram
The necessary steps carried out in a machine cycle can be represented graphically. Such a
graphical representation 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:
RD (low active): If it is high or 1, then no data is read by the microprocessor. If signal is low
or 0, then data is read by the microprocessor.
IO/M (low active): A high or 1 on this signal indicates I/O operation while a low or 0
indicates memory operation.
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.
Addressing Modes
Each instruction requires some data on which it has to operate. There are different techniques
to specify data for instructions. These techniques are called addressing modes. Intel 8085
uses the following addressing modes:
Direct Addressing
In this addressing mode, the address of the operand (data) is given in the instruction itself.
Example
STA 2400H: It stores the content of the accumulator in the memory location 2400H.
In this instruction, 2400H is the memory address where data is to be stored. It is given in the
instruction itself. The 2nd and 3rd bytes of the instruction specify the address of the memory
location. Here, it is understood that the source of the data is accumulator.
Register Addressing
In register addressing mode, the operand is in one of the general purpose registers. The
opcode specifies the address of the register(s) in addition to the operation to be performed.
Example:
In the above example, MOV A, B is 78H. Besides the operation to be performed the opcode
also specifies source and destination registers.
The opcode 78H can be written in binary form as 01111000. The first two bits, i.e. 0 1 are for
MOV operation, the next three bits 1 1 1 are the binary code for register A, and the last three
bits 000 are the binary code for register B.
Example
MOV A, M - Move the content of the memory location, whose address is in H-L pair
(i.e. 2500 H) to the accumulator.
HLT - Halt.
In the above program the instruction MOV A, M is an example of register indirect addressing.
For this instruction, the operand is in the memory. The address of the memory is not directly
given in the instruction. The address of the memory resides in H-L pair and this has already
been specified by an earlier instruction in the program, i.e. LXI H, 2500 H.
Immediate Addressing
In this addressing mode, the operand is specified within the instruction itself.
Example
LXI H, 2500 is an example of immediate addressing. 2500 is 16-bit data which is given in the
instruction itself. It is to be loaded into H-L pair.
Implicit Addressing
There are certain instructions which operate on the content of the accumulator. Such
instructions do not require the address of the operand.
Example
Status Flags
There is a set of five flip-flops which indicate status (condition) arising after the execution of
arithmetic and logic instructions. These are:
The programmer writes a program in assembly language using these instructions. These
instructions have been classified into the following groups:
Data Transfer Group
Instructions which are used to transfer the data from a register to another register from
memory to register or register to memory come under this group.
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.
Logical Group
The instructions in this group perform logical operation such as AND, OR, compare, rotate,
etc.
Branch Control Group
This group contains the instructions for conditional and unconditional jump, subroutine call
and return, and restart.
Unconditional Jump
Instruction cycle in 8085 microprocessor
Time required to execute and fetch an entire instruction is called instruction cycle. It
consists:
•Fetch cycle – The next instruction is fetched by the address stored in program
counter (PC) and then stored in the instruction register.
•Decode instruction – Decoder interprets the encoded instruction from instruction
register.
•Reading effective address – The address given in instruction is read from main
memory and required data is fetched. The effective address depends on direct
addressing mode or indirect addressing mode.
•Execution cycle – consists memory read (MR), memory write (MW), input output
read (IOR) and input output write (IOW)
The time required by the microprocessor to complete an operation of accessing memory
or input/output devices is called machine cycle. One time period of frequency of
microprocessor is called t-state. A t-state is measured from the falling edge of one clock
pulse to the falling edge of the next clock pulse.
Fetch cycle takes four t-states and execution cycle takes three t-states.
Timing diagram for fetch cycle or opcode fetch: