You are on page 1of 89

102045610 MT by Prof.

P M SHAH
The microprocessor is a multipurpose, programmable,
clock-driven, register based electronic device that reads
the instructions from a storage device called Memory,
accepts data as input, performs on them arithmetic or
logical operations according to those set of instructions
and then produces results as output.

102045610 MT by Prof. P M SHAH


Multipurpose:
Multiple use of microprocessors.

Programmable:
The microprocessor can perform different sets of
operations on the data it receives depending on the
sequence of instructions supplied in the given program.
By changing the program, the microprocessor
manipulates the data in different ways.

102045610 MT by Prof. P M SHAH


Clock Driven:
The microprocessor performs operations at specific instant of
time in a specific sequence.

Register Based:
Register is a device that hold the data.

Instructions:
Each microprocessor is designed to execute a specific group of
operations. This group of operations is called an instruction
set. This instruction set defines what microprocessor can and
cannot do.
102045610 MT by Prof. P M SHAH
Storage Device (Memory):
Memory is the location where information is kept while not in use.
Memory is a collection of storage devices.
Usually, each storage device holds one bit. Also, in most kinds of
memory, these storage devices are grouped into groups of 8. These
8 storage locations can only be accessed together. So, one can only
read or write in terms of bytes to and form memory.
Memory is usually measured by the number of bytes it can hold.
It is measured in Kilos, Megas and lately Gigas. A Kilo in computer
language is 210 =1024. So, a KB (KiloByte) is 1024 bytes. Mega is
1024 Kilos and Giga is 1024 Mega.

102045610 MT by Prof. P M SHAH


Storage Device (Memory):
When a program is entered into a computer, it is stored in
memory. Then as the microprocessor starts to execute
the instructions, it brings the instructions from memory
one at a time.

Memory is also used to hold the data.


The microprocessor reads (brings in) the data from
memory when it needs it and writes (stores) the results
into memory when it is done.
102045610 MT by Prof. P M SHAH
Accepts:
The data that the microprocessor manipulates must come
from somewhere.

It comes from what is called “input devices”.

These are devices that bring data into the system from the
outside world.

These represent devices such as a keyboard, a mouse,


switches, and the like.

102045610 MT by Prof. P M SHAH


Data:
The microprocessor has a very narrow view on life. It only
understands binary numbers.

A binary digit is called a bit (which comes from binary digit).

The microprocessor recognizes and processes a group of bits


together. This group of bits is called a “word”.

The number of bits in a Microprocessor’s word, is a measure


of its “abilities”.

102045610 MT by Prof. P M SHAH


Words, Bytes, etc.
The earliest microprocessor recognized 8-bit words.

They processed information 8-bits at a time. That’s why they are


called “8-bit processors”. They can handle large numbers, but in
order to process these numbers, they broke them into 8-bit pieces
and processed each group of 8-bits separately.

Later microprocessors were designed with 16-bit words.

A group of 8-bits were referred to as a “half-word” or “byte”.

A group of 4 bits is called a “nibble”.

Also, 32 bit groups were given the name “long word”.


102045610 MT by Prof. P M SHAH
Arithmetic and Logic Operations:
Every microprocessor has arithmetic operations such as add and
subtract as part of its instruction set.
Most microprocessors will have operations such as multiply and divide.

Some of newer ones will have complex operations such as square root.

In addition, microprocessors have logic operations as well. Such as


AND, OR, XOR, shift left, shift right, etc.

Again, the number and types of operations define the


microprocessor’s instruction set and depends on the specific
microprocessor.
102045610 MT by Prof. P M SHAH
Set of Instructions (Program):
A program is a sequence of instructions that bring data into the
microprocessor, processes it and sends it out.
There are many programming languages (C, C++, & JAVA…)
However, these programming languages can be grouped into
three main levels (these days a fourth level is developing).

Programming Languages:
Machine level language
Assembly level language
High level language

102045610 MT by Prof. P M SHAH


Produces:
For the user to see the result of the execution of the program,
the results must be presented in a human readable form.

Output:
The results must be presented on an output device.

This can be the monitor, a paper from the printer, a simple LED
or many other forms.

102045610 MT by Prof. P M SHAH


102045610 MT by Prof. P M SHAH
Internally, the microprocessor is made up of 3 main
units.
The Arithmetic/Logic Unit (ALU)
The Control Unit.
An array of registers for holding data while it is being
manipulated.

102045610 MT by Prof. P M SHAH


I/O
Input / Output
Register
ALU
Array

Control Unit Memory

ROM RAM

102045610 MT by Prof. P M SHAH


Memory stores information such as instructions and data in
binary format (0 and 1). It provides this information to the
microprocessor whenever it is needed.
Usually, There is a memory “sub-system” in a μP-based system
which includes:
The registers inside the microprocessor
Read Only Memory (ROM)
used to store data (programs) that does not change.
Random Access Memory (RAM) (also known as Read/Write Memory).
used to store information supplied by the user. Such as programs and data.

102045610 MT by Prof. P M SHAH


To execute a program:
the user enters its instructions in binary format into the
memory.
The microprocessor then reads these instructions and
whatever data is needed from memory, executes the
instructions and places the results either in memory or
produces it on an output device.

102045610 MT by Prof. P M SHAH


Input and output devices are the system’s means of
communicating with the outside world. These devices are
collectively known as peripherals.

Input devices transfer binary information from the outside world to the
microprocessor.
Examples of input devices are: keyboard, mouse, bar code reader, scanner and the
like.

Output devices transfer binary information from the microprocessor to the


outside world.
Theses include things like an LED, a monitor, a printer and the like.

102045610 MT by Prof. P M SHAH


A communication path between the microprocessor and
peripherals.
It is simply a group of wires carrying the voltages and curents
representing the different bit values.

The microprocessor communicates with only one


peripheral at a time.

Controlling the bus is done by the Control Unit.


102045610 MT by Prof. P M SHAH
Address Bus

Reg.
ALU
Array Memory Input Output

Data Bus
Control
Unit
Control Bus

102045610 MT by Prof. P M SHAH


The user has given the following instruction:
ADD R1, R2, R3
Which translates to:
add Register 1 to Register 2 and place the result in Register 3.
The control unit receives the bit pattern for this instruction
(0100011011) from memory.
It decodes the bit pattern and determines that this is an Add operation
(0100).
It also determines that the inputs to the addition come from Register R1
(01) and Register R2 (10).
It finally determines that the results go into register R3 (11).
102045610 MT by Prof. P M SHAH
EN EN EN EN
R1 R2 R3 R4

S0 S0
4 X 1 MUX 4 X 1 MUX
S1 S1

Adder

It issues a control signal connecting one input of the adder


(in the ALU) to R1 (in the Register Array) and the other
input to R2. Then after an appropriate amount of time, it
issues a control signal 102045610
to R3MTto store the ADDER output.
by Prof. P M SHAH
To execute a program, the microprocessor “reads” each
instruction from memory, “interprets” it, then “executes” it.
To use the right names for the cycles:
The microprocessor fetches each instruction,
decodes it,
Then executes it.

This sequence is continued until all instructions are


performed.

102045610 MT by Prof. P M SHAH


The number of bits that form the “word” of a microprocessor is
fixed for that particular processor.
These bits define a maximum number of combinations.
For example an 8-bit microprocessor can have at most 28 = 256 different
combinations.

However, in most microprocessors, not all of these combinations


are used.
Certain patterns are chosen and assigned specific meanings.
Each of these patterns forms an instruction for the microprocessor.
The complete set of patterns makes up the microprocessor’s
machine language.
102045610 MT by Prof. P M SHAH
Entering the instructions using hexadecimal is quite
easier than entering the binary combinations.
However, it still is difficult to understand what a program
written in hexadecimal does.
So, each company defines a symbolic code for the instruction.
These codes are called “mnemonics”.
The mnemonic for each instruction is usually a group of letters
that suggest the operation performed.

102045610 MT by Prof. P M SHAH


Using the example,
00111100 translates to 3C in hexadecimal
Its mnemonic is: “INR A”.
INR stands for “increment register” and A is short for
accumulator.

Another example is: 1000 0000,


Which translates to 80 in hexadecimal.
Its mnemonic is “ADD B”.
“Add register B to the accumulator and keep the result in the
accumulator”.
102045610 MT by Prof. P M SHAH
It is important to remember that a machine language and its
associated assembly language are completely machine
dependent.
In other words, they are not transferable from one microprocessor to a
different one.
For example, Motorolla has an 8-bit microprocessor called the
6800.
The 8085 machine language is very different from that of the 6800. So is
the assembly language.
A program written for the 8085 cannot be executed on the 6800 and vice
versa.

102045610 MT by Prof. P M SHAH


How does assembly language get translated into machine
language?
There are two ways:
1st there is “hand assembly”.
The programmer translates each assembly language instruction
into its equivalent hexadecimal code (machine language). Then
the hexadecimal code is entered into memory.
The other possibility is a program called an “assembler”, which does
the translation automatically.

102045610 MT by Prof. P M SHAH


The 8085 uses three separate busses to perform its
operations
The address bus.
The data bus.
The control bus.

102045610 MT by Prof. P M SHAH


16 bits wide (A0 A1…A15)
Therefore, the 8085 can access locations with numbers
from 0 to 65,536. Or, the 8085 can access a total of 64K
addresses.
“Unidirectional”
Information flows out of the microprocessor and into the
memory or peripherals.
When the 8085 wants to access a peripheral or a memory
location, it places the 16-bit address on the address bus and
then sends the appropriate control signals.
102045610 MT by Prof. P M SHAH
8 bits wide (D0 D1…D7)
“Bi-directional”
Information flows both ways between the microprocessor
and memory or I/O.
The 8085 uses the data bus to transfer the binary information.
Since the data bus has 8-bits only, then the 8085 can
manipulate data 8 bits at-a-time only.

102045610 MT by Prof. P M SHAH


There is no real control bus. Instead, the control bus
is made up of a number of single bit control signals.
Read Signal (RD)
Write Signal (WR)

102045610 MT by Prof. P M SHAH


All of the operations of the microprocessor can be
classified into one of three types:
- Microprocessor Initiated Operations
- Internal Operations
- Peripheral Initiated Operations

102045610 MT by Prof. P M SHAH


These are operations that the microprocessor itself
starts.
These are usually one of 4 operations:
Memory Read
Memory Write
I/O Read (Get data from an input device)
I/O write (Send data to an output device)

102045610 MT by Prof. P M SHAH


It is important to note that the microprocessor treats
memory and I/O devices the same way.
Input and output devices simply look like memory locations to the
microprocessor.
For example, the keyboard may look like memory address A3F2H. To get
what key is being pressed, the microprocessor simply reads the data at
location A3F2H.
The communication process between the microprocessor and
peripheral devices consist of the following three steps:
Identify the address.
Transfer the binary information.
Provide the right timing signals.
102045610 MT by Prof. P M SHAH
To read the contents of a memory location, the
following steps are taken place:
The microprocessor places the 16-bit address of the memory
location on the address bus.
The microprocessor activates a control signal called “memory
read” which enables the memory chip.
The memory decodes the address and identifies the right location.
The memory places the contents on the data bus.
The microprocessor reads the value of the data bus after a certain
amount of time.
102045610 MT by Prof. P M SHAH
The 8085 can perform a number of internal operations. Such as:
storing data, Arithmetic & Logic operations, Testing for condition..
To perform these operations, the microprocessor needs an internal
architecture similar to the following:

A CCUMULATOR S Z AC
F LAGS P CY

B C
D E
H L
S TACK P OINTER
P ROGRAM C OUNTER

A DDRESS 16 8 D ATA
102045610 MT by Prof. P M SHAH
General Purpose Registers:
B, C, D, E, H & L
The Accumulator
Special Register in a ALU and used as one of the operand in Arithmetic &
Logical operations.
The flag
It is a flip-flop. The status of which reflects the result.
The Program Counter (PC)
This is a register that is used to control the sequencing of the execution of
instructions.
This register always holds the address of the next instruction.
Since it holds an address, it must be 16 bits wide.
102045610 MT by Prof. P M SHAH
The Stack pointer
The stack pointer is also a 16-bit register that is used to point
into memory.
The memory this register points to is a special area called the
stack.
The stack is an area of memory used to hold data that will be
retreived soon.
The stack is usually accessed in a Last In First Out (LIFO)
fashion.

102045610 MT by Prof. P M SHAH


External devices can initiate (start) one of the 4
following operations:
Reset
All operations are stopped and the program counter is reset to 0000.

Interrupt
The microprocessor’s operations are interrupted and the
microprocessor executes what is called a “service routine”.
This routine “handles” the interrupt, (perform the necessary
operations). Then the microprocessor returns to its previous
operations and continues.

102045610 MT by Prof. P M SHAH


Ready
The 8085 has a pin called RDY. This pin is used by external devices to
stop the 8085 until they catch up.
As long as the RDY pin is low, the 8085 will be in a wait state.

Hold
The 8085 has a pin called HOLD. This pin is used by external devices to
gain control of the busses.
When the HOLD signal is activated by an external device, the 8085
stops executing instructions and stops using the busses.
This would allow external devices to control the information on the
busses. Example DMA.

102045610 MT by Prof. P M SHAH


The 8085 is an 8-bit general purpose microprocessor
that can address 64K Byte of memory.
It has 40 pins and uses +5V for power.
The pins on the chip can be grouped into 6 groups:
Address Bus.
Data Bus.
Control and Status Signals.
Power supply and frequency.
Externally Initiated Signals.
Serial I/O ports.

102045610 MT by Prof. P M SHAH


Vcc GND
X1
X2

H IGH -O RDER
A DDRESS B US
SOD
SID

8
TRAP 0 M ULTIPLEXED
RST7.5
RST6.5
RST5.5
8 A DD /D ATA B US

INTR
READY
5
HOLD ALE
RESETIN’ S0
S1
INTA’ IO/M’
HLDA RD’
WR’

RESET OUT CLOCK OUT

102045610 MT by Prof. P M SHAH


The address bus has 8 signal lines A8 – A15 which are
unidirectional.
The other 8 address bits are multiplexed (time shared) with
the 8 data bits.
So, the bits AD0 – AD7 are bi-directional and serve as A0 – A7 , D0 – D7
at the same time.
During the execution of the instruction, these lines carry the address bits
during the early part, then during the late parts of the execution, they
carry the 8 data bits.
In order to separate the address from the data, we can use a latch to
save the value before the function of the bits changes.

102045610 MT by Prof. P M SHAH


There are 4 main control and status signals. These
are:
ALE: Address Latch Enable. This signal is a pulse that become 1
when the AD0 – AD7 lines have an address on them. It becomes 0
after that. This signal can be used to enable a latch to save the
address bits from the AD lines.
𝑹𝑫: Read. Active low.
𝑾𝑹: Write. Active low.
ഥ This signal specifies whether the operation is a memory
𝑰𝑶/𝑴:
operation (IO/M=0) or an I/O operation (IO/M=1).
S1 and S0 : Status signals to specify the kind of operation being
performed .Usually un-used in small systems.
102045610 MT by Prof. P M SHAH
There are 3 important pins in the frequency & control
group.
X1 and X2 are the inputs from the crystal or clock generating
circuit.
The frequency is internally divided by 2.
So, to run the microprocessor at 3 MHz, a Crystal running at 6
MHz should be connected to the X1 and X2 pins.

CLK (OUT): An output clock pin to drive the clock of the rest of
the system.
102045610 MT by Prof. P M SHAH
SID SOD

INTERRUPT CONTROLLER SERIAL I/O CONTROL

8-BIT INTERNAL DATA BUS

ACCUMULATOR TEMPORARY FLAG (5) INSTRUCTION MULTIPLEXER &


(8) REGISTER (8) FLIP-FLOPS REGISTER (8) REG. SEL.
B (8) C (8)
D (8) E (8)
ARITHMETIC & INSTRUCTION
LOGIC UNIT DECODER & H (8) L (8)
(ALU) MACHINE STACK POINTER (16)
CYCLE
ENCODING PROGRAM COUNTER (16)
VCC
INCR./DECR. ADDRESS LATCH
GND
X1
CONTROL & TIMING SIGNALS MULTIPLEXER
X2 ADDRESS BUFFER DATA/ADD
(8) BUFFER (8)

102045610
COUT RDY RD WR ALE S0 S1 IO/M MT by Prof.
HLD HLDA RSTPI MRST
SHAH
O A15-A8 AD7-AD0
In addition to the arithmetic & logic circuits, the ALU
includes the accumulator, which is part of every
arithmetic & logic operation.

Also, the ALU includes a temporary register used for


holding data temporarily during the execution of the
operation. This temporary register is not accessible by
the programmer.

102045610 MT by Prof. P M SHAH


There is also the flags register whose bits are affected by
the arithmetic & logic operations.
S-sign flag
The sign flag is set if bit D7 of the accumulator is set after an
arithmetic or logic operation.
Z-zero flag
Set if the result of the ALU operation is 0. Otherwise is reset. This
flag is affected by operations on the accumulator as well as other
registers. (DCR B).
AC-Auxiliary Carry
This flag is set when a carry is generated from bit D3 and passed
to D4. This flag is used only internally for BCD operations.
P-Parity flag
After an ALU operation if the result has an even # of 1’s the p-flag
is set. Otherwise it is cleared. So, the flag can be used to indicate
even parity.
CY-carry flag
After an ALU operation if the result has a carry generated then CY-
flag is set. Otherwise it is cleared. (e.g. the flag can be used to
indicate 8-bit addition results into 9 bits).
102045610 MT by Prof. P M SHAH
Since the 8085 is an 8-bit device it can have up to 28 (256) instructions.
However, the 8085 only uses 246 combinations that represent a total
of 74 instructions.
– Most of the instructions have more than one format.

These instructions can be grouped into five different groups:


Data Transfer Operations
Arithmetic Operations
Logic Operations
Branch Operations
Machine Control Operations

102045610 MT by Prof. P M SHAH


Each instruction has two parts.
The first part is the task or operation to be performed.
This part is called the “opcode” (operation code).

The second part is the data to be operated on


Called the “operand”.

102045610 MT by Prof. P M SHAH


There are different ways for specifying the operand:
The operand may be an internal register (Register)
MOV A , B
The operand may be an 8-bit number (Immediate Data)
MVI A , 35H
The operand may be a 16-bit address (Memory Address)
LDA 4000H
The operand may be a pointer pointing to the memory
Address (Indirect Address)
MOV A , M
102045610 MT by Prof. P M SHAH
Pass on
The Butter

102045610 MT by Prof. P M SHAH


Pass
The Bowl

102045610 MT by Prof. P M SHAH


Item 17
on the Menu

102045610 MT by Prof. P M SHAH


I will have what
Ms Mona has
ordered

102045610 MT by Prof. P M SHAH


Pass on Immediate
The Butter Operand

102045610 MT by Prof. P M SHAH


Pass Register
The Bowl Operand

102045610 MT by Prof. P M SHAH


Item 17 Direct Address
as Operand
on the Menu

102045610 MT by Prof. P M SHAH


I will have what
Ms Mona has Indirect Address
ordered as Operand

102045610 MT by Prof. P M SHAH


Depending on the operand type, the instruction may have
different sizes. It will occupy a different number of memory
bytes.
Typically, all instructions occupy one byte only.
The exception is any instruction that contains immediate data or a
memory address.
Instructions that include immediate data use two bytes.
– One for the opcode and the other for the 8-bit data.
Instructions that include a memory address occupy three bytes.
– One for the opcode, and the other two for the 16-bit address.

102045610 MT by Prof. P M SHAH


Depending on the operand type, the instruction may have
different sizes. It will occupy a different number of memory
bytes.
Typically, all instructions occupy one byte only.
The exception is any instruction that contains immediate data or a
memory address.
Instructions that include immediate data use two bytes.
– One for the opcode and the other for the 8-bit data.
Instructions that include a memory address occupy three bytes.
– One for the opcode, and the other two for the 16-bit address.

102045610 MT by Prof. P M SHAH


Operation: Copy contents of register B in to register A.

MOV A , B
Operation: MOV
Operand: A , B
Binary Code:
0011 1000 78 Single byte.

102045610 MT by Prof. P M SHAH


Operation: Load an 8-bit number into the accumulator.

MVI A , 32
Operation: MVI A
Operand: The number 32
Binary Code:
0011 1110 3E 1st byte.
0011 0010 32 2nd byte.

102045610 MT by Prof. P M SHAH


Operation: Load Accumulator with the content of
memory location 4000.

LDA 4000
Opcode: LDA
Operand: 4000
Binary code:
0011 1010 3A 1st byte.
0000 0000 00 2nd byte
0100 0000 40 3rd byte
102045610 MT by Prof. P M SHAH
Operation: Load Accumulator with the content of
memory location pointed by HL register pair.

MOV A , M
Opcode: MOV
Operand: A , M
Binary code:
0111 1110 7E Single byte.

102045610 MT by Prof. P M SHAH


To understand how the microprocessor operates and
uses different signals, we should study the process of
communication between the microprocessor and
memory during a memory read or write operation.
Lets look at timing and the data flow of an instruction
fetch operation.

102045610 MT by Prof. P M SHAH


Lets assume that we are trying to fetch the instruction at memory
location 1000. That means that the program counter is now set to
that value.
The following is the sequence of operations:
The program counter places the address value on the address bus and
the controller issues a RD signal.
The memory’s address decoder gets the value and determines which
memory location is being accessed.
The value in the memory location is placed on the data bus.
The value on the data bus is read into the instruction decoder inside
the microprocessor.
After decoding the instruction, the control unit issues the proper
control signals to perform the operation.
102045610 MT by Prof. P M SHAH
Data Bus

Internal Bus

B C
Instr. D E
ALU H L Memory
Dec. SP
PC

Control Add. Bus


logic

RD

102045610 MT by Prof. P M SHAH


– At T1, high order 8 address bits are placed on the address lines A8 – A15
and low order address bits are placed on AD7–AD0. The ALE signal goes
high to indicate that AD7–AD0 are carrying an address. At exactly the
same time, the IO/M signal goes low to indicate a memory operation.
– At the beginning of the T2 cycle, the low order 8 address bits are
removed from AD7–AD0 and the controller sends the Read (RD) signal to
the memory. The signal remains low (active) for two clock periods to
allow for slow devices. During T2 , memory places the data(instruction)
from the memory location on the lines AD7– AD0.
– During T3 the RD signal is Disabled (goes high). This turns off the output
Tri-state buffers in the memory. That makes the AD7– AD0 lines go to
high impedence mode. 102045610 MT by Prof. P M SHAH
From the above description, it becomes obvious that the AD7– AD0
lines are serving a dual purpose and that they need to be
demultiplexed to get all the information.
The high order bits of the address remain on the bus for three clock
periods. However, the low order bits remain for only one clock period
and they would be lost if they are not saved externally. Also, notice that
the low order bits of the address disappear when they are needed
most.
To make sure we have the entire address for the full three clock cycles,
we will use an external latch to save the value of AD7– AD0 when it is
carrying the address bits. We use the ALE signal to enable this latch.
102045610 MT by Prof. P M SHAH
8085
A15-A8

ALE
AD7-AD0 Latch
A7-A0

D7 – D0

Given that ALE operates as a pulse during T1, we will be able to


latch the address. Then when ALE goes low, the address is
saved and the AD7– AD0 lines can be used for their purpose as
the bi-directional data lines.
102045610 MT by Prof. P M SHAH
AD7 D7 Q7 A7
EN

AD6 D6 Q6 A6
EN

AD0 D0 Q0 A0
EN
LE OE

ALE
102045610 MT by Prof. P M SHAH
The 8085 generates a single RD signal. However, the signal needs
to be used with both memory and I/O. So, it must be combined
with the IO/M signal to generate different control signals for the
memory and I/O.
Keeping in mind the operation of the IO/M signal we can use the following
ckt to generate the right set of signals:

102045610 MT by Prof. P M SHAH


102045610 MT by Prof. P M SHAH
CLK

A15-A8 10h 10h 10h

AD7-AD0 00h OPCODE

ALE

RD
IO/M,
S1,S0

WR
102045610 MT by Prof. P M SHAH
From the above discussion, we can define terms that will
become handy later on:
T-State: One subdivision of an operation. A T-state lasts for one clock
period.
An instruction’s execution length is usually measured in a number of T-states.
Machine Cycle: The time required to complete one operation of accessing
memory, I/O, or acknowledging an external request.
This cycle may consist of 3 to 6 T-states.
Instruction Cycle: The time required to complete the execution of an
instruction.
In the 8085, an instruction cycle may consist of 1 to 6 machine cycles.

102045610 MT by Prof. P M SHAH


The 8085 executes several types of instructions with
each requiring a different number of operations of
different types. However, the operations can be grouped
into a small set.
The three main types are:
Memory Read and Write.
I/O Read and Write.
Request Acknowledge.

These can be further divided into various operations


(machine cycles).
102045610 MT by Prof. P M SHAH
Machine Cycle IO/M’ S1 S0 Control Signal
Opcode Fetch 0 1 1 RD’ = 0
Memory Read 0 1 0 RD’ = 0
Memory Write 0 0 0 WR’ = 0
I/O Read 1 1 0 RD’ = 0
I/O Write 1 0 1 WR’ = 0
Interrupt
1 1 1 INTA’ = 0
Acknowledge
Halt Z 0 0
RD’ = Z, WR’ = Z,
Hold Z X X
INTA’ =1
Reset Z X X
102045610 MT by Prof. P M SHAH
The first step of executing any instruction is the Opcode
fetch cycle.
In this cycle, the microprocessor brings in the instruction’s Opcode
from memory.
To differentiate this machine cycle from the very similar “memory read”
cycle, the control & status signals are set as follows:
– IO/M=0, s0 and s1 are both 1.

This machine cycle has four T-states.


The 8085 uses the first 3 T-states to fetch the opcode.
T4 is used to decode it.
It is also possible for an instruction to have 6 T-states in an opcode
fetch machine cycle.
102045610 MT by Prof. P M SHAH
102045610 MT by Prof. P M SHAH
The memory read machine cycle is exactly the same as
the op-code fetch except:
It only has 3 T-states
The S0 signal is set to 0 instead.

102045610 MT by Prof. P M SHAH


To understand the memory read machine cycle, let’s study the
execution of the following instruction:
MVI A, 76h 2000h 3Eh
In memory, this instruction looks like: 2001h 76h
The first byte 3EH represents the op-code for loading a byte into the
accumulator (MVI A), the second byte is the data to be loaded.

The 8085 needs to read these two bytes from memory before it
can execute the instruction. Therefore, it will need at least two
machine cycles.
The first machine cycle is the op-code fetch discussed earlier.
The second machine cycle is the Memory Read Cycle.
102045610 MT by Prof. P M SHAH
102045610 MT by Prof. P M SHAH
STA 5065H 2010h 32h
2011h 65h
2012h 50h
Opcode fetch to fetch the opcode (32H) from location 2010H, decode
it and determine that 2 more bytes are needed (4 T-states).
Memory read to read the low order byte of the address (65H) (3 T-
states).
Memory read to read the high order byte of the address (50H) (3 T-
states).
A memory write to write the contents of the accumulator into the
memory location. (3 T-States).

102045610 MT by Prof. P M SHAH


Opcode Fetch Machine Cycle Memory Read Memory Read Memory Write

102045610 MT by Prof. P M SHAH


In a memory write operation:
The 8085 places the address (2065H) on the address bus
Identifies the operation as a memory write (IO/M=0, s1=0,
s0=1).
Places the contents of the accumulator on the data bus and
asserts the signal WR.
During the last T-state, the contents of the data bus are saved
into the memory location.

102045610 MT by Prof. P M SHAH


102045610 MT by Prof. P M SHAH
Thank
You
102045610 MT by Prof. P M SHAH

You might also like