Unit 3 Instruction Cycle Final
Unit 3 Instruction Cycle Final
Microprocessor
Unit 3: Instruction Cycle
Syllabus:
Once the execution of an instruction is complete, the microprocessor returns to the fetch step to
fetch the next instruction to be executed. This cycle repeats until the program is complete or
interrupted.
T states in Microprocessor
A portion of an operation carried out in one system clock period is called as T-state.
It is one subdivision of the operation performed in one clock period.
It is part of the machine cycle.
One clock period is equal to one t state.
Signals Significance
IO/M = 1 (read/write operation to an IO device)
̅
IO/ 𝑀 IO/M = 0 (read/write operation to the memory))
S1 and S1 and S0 = 00 (Halt)
S0 S1 and S0 = 01 (A write operation)
S1 and S0 = 10 (A read operation)
S1 and S0 = 11 (Either opcode fetch or interrupt acknowledge)
op-code fetch
The opcode fetch machine cycle involves the fetching of the opcode of the instruction to be
executed and the decoding process of that opcode. Usually, it consists of four T states.
1st T state
During the first T state, the address of the location where the opcode is stored is loaded on the
address bus. In 8085, this address is stored in a 16-bit register called the program counter.
Higher eight bits of the address are loaded on A8-A15, and the lower eight bits of the address
are loaded into AD0-AD7 for de-multiplexing.
2nd T state
By the beginning of the 2nd T state or the end of 1st T state, the ALE signal goes low. By this
time, 8085 expects that the lower address bits are latched, and AD0-AD7 is free to be used as
a data bus.
At the beginning of the second T state, ̅̅̅̅
𝑅𝐷 goes low, indicating that the read process has
started. Meanwhile, higher address bits are present in A8-A15, and lower address bits are
expected to be latched.
As 𝑅𝐷 ̅̅̅̅ goes low, the opcode (eight bits) is loaded into the data bus AD0-AD7 . In above case
41H is loaded into the data bus AD0-AD7.
3rd T state
The opcode loaded on the data bus is present there until the middle of the third T state.
̅̅̅̅ goes up, indicating that the read operation is completed and ‘the
During the third T state, 𝑅𝐷
opcode is fetched’ and placed in the instruction register.
The data on the data bus and the higher address bits on A8-A15 exist until the middle of this T
state.
4th T state
During the fourth T state, the fetched opcode is decoded. There is nothing much to observe in
the timing diagram during this process.
During the fourth T state, after decoding the opcode, the microprocessor decides if it needs
fifth and sixth T states, or should proceed to the next machine cycle.
PC is incremented by 1 here or in the sixth T state if the OFMC is extended upto sixth T state.
Memory read
Contents from a memory location are read during the memory read machine cycle (MRMC). This
cycle is also known as the operand fetch machine cycle. But there are cases when MRMC is not used
for operand fetch but for reading data at given memory location. This machine cycle spans over three
T states.
There are certain machine cycles where Program Counter is incremented and some, where it is
not incremented.
If the address is loaded into the address bus from the program counter, then PC in incremented
at the end of that machine cycle otherwise PC is not incremented.
For reading the operands, memory read machine cycles are executed. In such machine cycles,
PC is incremented as the address is loaded from the PC.
But during the execution of instruction MOV A, M the last machine cycle is the memory read
machine cycle in which the address is loaded on the address bus from the HL register. Hence,
the PC is not incremented in this case
1st T state
Higher address bits loaded into A8-A15.
Lower address bits loaded into AD0-AD7.
ALE signal goes high in the beginning to indicate that AD0-AD7 contains lower address bits.
IO/𝑀̅ goes low since it is a memory operation.
S1 and S0 become 1 and 0 respectively, indicating Memory Read Machine Cycle.
ALE goes low by the end of the first T state. Lower address bits are expected to be latched by
this time.
Memory write
Contents are written to a memory location/stack during a memory write machine cycle
(MWMC). This machine cycle spans over three T states. Each of these T states are explained here
along with the timing diagram. PC is not incremented in this machine cycle. This is very similar to
MRMC, except a few differences.
1st T state
Higher address bits loaded into A8-A15.
Lower address bits loaded into AD0-AD7.
ALE signal goes high in the beginning to indicate that AD0-AD7 contains lower address bits.
IO/𝑀 ̅̅̅goes low since it is a memory operation.
S1 and S0 become 0 and 1 respectively, indicating MWMC.
ALE goes low by the end of the first T state. Lower address bits are expected to be latched by
this time.
There is an important point to be noted here. In 8085, IO devices have an 8-bit address. But we
have AD0-AD7 and A8-A15 for addresses. So, whenever the microprocessor is exchanging data with
and IO device (during IORMC and IOWMC), the same 8 bits are loaded into both the upper address
1st T state
8-bit address is loaded into A8-A15.
The same 8-bit address is loaded into AD0-AD7.
ALE signal goes high in the beginning to indicate that AD0-AD7 contains address bits and not
data bits.
IO/𝑀 ̅ goes high since the microprocessor is dealing with an IO device.
S1 and S0 become 1 and 0 respectively, indicating a ‘read’ machine cycle.
ALE goes low by the end of the first T state. Address bits in AD0-AD7 are expected to be
latched by this time.
1st T state
8-bit address is loaded into A8-A15.
The same 8-bit address is loaded into AD0-AD7.
ALE signal goes high in the beginning to indicate that AD0-AD7 contains address bits.
IO/𝑀 ̅̅̅ goes high since the microprocessor is dealing with an IO device.
To interrupt the 8085 microprocessor, we usually execute one of the two instructions – RST
or CALL.
The RST instruction has only one interrupt acknowledge cycle of 6 T-states. Whereas the
CALL instruction has three interrupt acknowledge cycles. RST is a one-byte instruction and CALL is
a three-byte instruction that’s why they are one and three T states respectively..
The addresses for the Interrupt Subroutine (ISR) will be provided by the instructions themselves.
Hence, the PC won’t be incremented.
1st T state
The first T state of all the machine cycles involving data transfer is for the de-multiplexing of
AD0-AD7. The same is the case here. A8-A15 contains higher address bits. ALE signal goes
high. AD0-AD7 contains address for that interval of time.
The difference here is that the 𝐼𝑁𝑇𝐴
̅̅̅̅̅̅̅̅signal is high. RD and WR both are low. IO/M = 1 and
S1S0 = 1
Notice that the instruction cycle of RST instruction consists of three machine cycles.
The first one is the Interrupt Acknowledge Machine Cycle explained above. At the end of the
IAMC, the instruction is decoded.
Since it is RST instruction, two more machine cycles, both of them being MWMC, are
executed.
In the second and third machine cycles, the contents of the program counter are written on the
stack and after the execution of RST instruction, program execution jumps to the interrupt
service routine.
One such example where this situation occurs is the DAD instruction. So, let us have a look at the
timing diagram of DAD instruction and understand more about BIMC.
Example :
DAD Rp
Here, DAD is a mnemonic, which stands for Double ADd and also rp stands for any one of the
register pairs BC, DE, or HL
In this instruction HL register pair works as Accumulator. Because the 16-bit content of rp will
be added with HL register pair content and sum thus produced will be stored back on to HL again.
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. Here, B is the destination register and C is the source register
whose contents need to be transferred to the destination register.
Opcode: MOV
Operand: B and C
2000: MOV B, C
MOV B, C
Suppose B register content is DBH, H register content is 40H, and L register content is 50H. Let
us say location 4050H has the data value 24H. When the 8085 executes this instruction, the contents
of B register will change to 24H, as shown below.
MVI instruction stores the immediately provided 8-bit data into the specified location, which
can be either a register or a memory location. Suppose we have instruction
MVI A, 45H
This is a 2-byte instruction. One byte for the opcode, second byte for the operand.
So, the first machine cycle will be OFMC, during which the microprocessor will read the opcode.
During the second machine cycle, the microprocessor will read the operand, which is the 8-bit
number 45H. So, the second machine cycle will be MRMC. You can refer to the timing diagram of
the MVI instruction above.
The I/O read cycle is executed by the processor to read a data byte from I/O port or from
peripheral, which is I/O mapped in the system. The 8-bit port address is placed both in the lower and
higher order address bus. The processor takes three T-states to execute this machine cycle.
Example:
IN 05H
Example:
OUT 05H
LDA is a mnemonic that stands for LoaD. It load Accumulator with the contents from memory. In
this instruction Accumulator will get initialized with 8-bit content from the 16-bit memory address as
indicated in the instruction as a 16. Example:
LDA 4050H
2009 50
200A 40
The initial content of memory address 4050H is ABH. Initially Accumulator content is CDH.
As after execution A will be initialized with value ABH. Memory location 4050H will still remain
with the content ABH. The results of execution of this instruction is as below –
Before After
A CDH ABH
STA instruction
Example :
STA 526AH
STA means Store Accumulator -The contents of the accumulator is stored in the specified
address (526A).
The opcode of the STA instruction is said to be 32H. It is fetched from the memory 41FFH
(see fig). - OF machine cycle
Then the lower order memory address is read (6A). - Memory Read Machine Cycle
Read the higher order memory address (52).- Memory Read Machine Cycle
The combination of both the addresses are considered and the content from accumulator is
written in 526A. - Memory Write Machine Cycle
Assume the memory address for the instruction and let the content of accumulator is C7H. So,
C7H from accumulator is now stored in 526A.
Interfacing:
A microprocessor has to be interfaced with various peripherals to perform various functions. Let's
discuss about the Interfacing techniques in detail.
We know that a microprocessor is the CPU of a computer.
A microprocessor can perform some operation on a data and give the output. But to perform the
operation we need an input to enter the data and an output to display the results of the operation.
Interfacing Types
There are two types of interfacing in context of the 8085 processor.
(a) Memory Interfacing.
(b) I/O Interfacing.
Memory Interfacing:
While executing an instruction, there is a necessity for the microprocessor to access memory
frequently for reading various instruction codes and data stored in the memory. The interfacing circuit
aids in accessing the memory.
Memory requires some signals to read from and write to registers. Similarly the microprocessor
transmits some signals for reading or writing a data.
The interfacing process involves matching the memory requirements with the microprocessor
signals. The interfacing circuit therefore should be designed in such a way that it matches the memory
signal requirements with the signals of the microprocessor.
Microprocessor need to access memory quite frequently to read instructions and data stored in
memory; the interface circuit enables that access.
The interface process involves designing a circuit that will match the memory requirements with
the microprocessor signal. Memory has certain signal requirements to read from and write into
memory. Similarly Microprocessor initiates the set of signals when it wants to read from and write
into memory.
8085 has 16 address lines (A0 - A15), hence a maximum of 64 KB (= 216 bytes) of memory
locations can be interfaced with it.
The memory address space of the 8085 takes values from 0000H to FFFFH.
The 8085 initiates set of signals such as IO/M, RD’ and WR’ when it wants to read from and
write into memory.
Similarly, each memory chip has signals such as CE or CS (chip enable or chip select), OE or
RD’ (output enable or read) and WE or WR’ (write enable or write) associated with it.
8085 places 16-bit address on address bus and with this address only one register should be
selected (only 11 low order address lines are required).
Remaining 8085 address lines (A15-A11) should be decoded to generate chip select.
8085 provides two signal-IO/M’ and RD’– to indicate that is memory read operation MEMR’.
(Similarly signal-IO/M’ and WR’– indicates memory write operation MEMW’).
Primary Function of memory interfacing is that the microprocessor should be able to read from and
write into a given register of a memory chip:
I/O Interfacing:
We know that keyboard and Displays are used as communication channel with outside world. So
it is necessary that we interface keyboard and displays with the microprocessor. This is called I/O
interfacing. In this type of interfacing we use latches and buffers for interfacing the keyboards and
displays with the microprocessor.
----------------------------------------------End Of Unit-3-------------------------------------------