Lecture
Lecture
Each instruction in 8085 microprocessor consists of two part- operation code (opcode) and
operand. The opcode is a command such as ADD and the operand is an object to be
operated on, such as a byte or the content of a register.
Instruction Cycle: The time taken by the processor to complete the execution of an
instruction. An instruction cycle consists of one to six machine cycles.
Machine Cycle: The time required to complete one operation; accessing either the memory
or I/O device. A machine cycle consists of three to six T-states.
T-State: Time corresponding to one clock period. It is the basic unit to calculate execution
of instructions or programs in a processor.
Opcode fetch
Operand fetch
Memory read/write
I/O read/write
Memory read/write
I/O read/write
Interrupt request acknowledge
It is the first step in the execution of any instruction. The timing diagram of this cycle is
given in Fig. 7.
The following points explain the various operations that take place and the signals that are
changed during the execution of opcode fetch machine cycle:
T1 clock cycle
i. The content of PC is placed in the address bus; AD0 - AD7 lines contains lower bit
address and A8 A15 contains higher bit address.
ii. IO/M signal is low indicating that a memory location is being accessed. S1 and S0
also changed to the levels as indicated in Table 1.
iii. ALE is high, indicates that multiplexed AD0 AD7 act as lower order bus.
T2 clock cycle
i. The opcode available on the data bus is read by the processor and moved to the
instruction register.
ii. The RD signal is deactivated by making it logic 1.
T4 clock cycle
i. The processor decode the instruction in the instruction register and generate the
necessary control signals to execute the instruction. Based on the instruction further
operations such as fetching, writing into memory etc takes place.
The memory read cycle is executed by the processor to read a data byte from memory. The
machine cycle is exactly same to opcode fetch except: a) It has three T-states b) The S0
signal is set to 0. The timing diagram of this cycle is given in Fig. 8.
Fig. 8 Timing diagram for memory read machine cycle
The memory write cycle is executed by the processor to write a data byte in a memory
location. The processor takes three T-states and WR signal is made low. The timing
diagram of this cycle is given in Fig. 9.
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. The timing diagram of this cycle is given in Fig. 10.
Fig. 9 Timing diagram for memory write machine cycle
The I/O write cycle is executed by the processor to write a data byte to I/O port or to a
peripheral, which is I/O mapped in the system. The processor takes three T-states to execute
this machine cycle. The timing diagram of this cycle is given in Fig. 11.
The instruction and the corresponding codes and memory locations are given in Table 5.
Table 5 IN instruction
i. During the first machine cycle, the opcode DB is fetched from the memory, placed
in the instruction register and decoded.
ii. During second machine cycle, the port address 80H is read from the next memory
location.
iii. During the third machine cycle, the address 80H is placed in the address bus and the
data read from that port address is placed in the accumulator.
7. 8085 INTERRUPTS
Interrupt Structure:
Interrupt is the mechanism by which the processor is made to transfer control from its
current program execution to another program having higher priority. The interrupt signal
may be given to the processor by any external peripheral device.
The program or the routine that is executed upon interrupt is called interrupt service routine
(ISR). After execution of ISR, the processor must return to the interrupted program. Key
features in the interrupt structure of any microprocessor are as follows:
Types of Interrupts:
Interrupts are classified based on their maskability, IVA and source. They are classified as:
i. Vectored and Non-Vectored Interrupts
Vectored interrupts require the IVA to be supplied by the external device that
gives the interrupt signal. This technique is vectoring, is implemented in
number of ways.
Non-vectored interrupts have fixed IVA for ISRs of different interrupt
signals.
ii. Maskable and Non-Maskable Interrupts
Maskable interrupts are interrupts that can be blocked. Masking can be done
by software or hardware means.
Non-maskable interrupts are interrupts that are always recognized; the
corresponding ISRs are executed.
iii. Software and Hardware Interrupts
Software interrupts are special instructions, after execution transfer the
control to predefined ISR.
Hardware interrupts are signals given to the processor, for recognition as an
interrupt and execution of the corresponding ISR.
The following sequence of operations takes place when an interrupt signal is recognized:
i. Save the PC content and information about current state (flags, registers etc) in the
stack.
ii. Load PC with the beginning address of an ISR and start to execute it.
iii. Finish ISR when the return instruction is executed.
iv. Return to the point in the interrupted program where execution was interrupted.
Software Interrupts:
8085 instruction set includes eight software interrupt instructions called Restart (RST)
instructions. These are one byte instructions that make the processor execute a subroutine at
predefined locations. Instructions and their vector addresses are given in Table 6.
8085 have five hardware interrupts INTR, RST 5.5, RST 6.5, RST 7.5 and TRAP. Their
IVA and priorities are given in Table 7.
Masking of Interrupts:
Masking can be done for four hardware interrupts INTR, RST 5.5, RST 6.5, and RST 7.5.
The masking of 8085 interrupts is done at different levels. Fig. 13 shows the organization of
hardware interrupts in the 8085.
RST 7.5 alone has a flip-flop to recognize edge transition. The DI instruction reset interrupt
enable flip-flop in the processor and the interrupts are disabled. To enable interrupts, EI
instruction has to be executed.
SIM Instruction:
The SIM instruction is used to mask or unmask RST hardware interrupts. When executed,
the SIM instruction reads the content of accumulator and accordingly mask or unmask the
interrupts. The format of control word to be stored in the accumulator before executing SIM
instruction is as shown in Fig. 14.
In addition to masking interrupts, SIM instruction can be used to send serial data on the
SOD line of the processor. The data to be send is placed in the MSB bit of the accumulator
and the serial data output is enabled by making D6 bit to 1.
RIM Instruction:
RIM instruction is used to read the status of the interrupt mask bits. When RIM instruction
is executed, the accumulator is loaded with the current status of the interrupt masks and the
pending interrupts. The format and the meaning of the data stored in the accumulator after
execution of RIM instruction is shown in Fig. 15.
In addition RIM instruction is also used to read the serial data on the SID pin of the
processor. The data on the SID pin is stored in the MSB of the accumulator after the
execution of the RIM instruction.
Fig. 15 Accumulator bit pattern after execution of RIM instruction
Ex: Write an assembly language program to enables all the interrupts in 8085 after reset.
EI : Enable interrupts
Timing of Interrupts:
The interrupts are sensed by the processor one cycle before the end of execution of each
instruction. An interrupts signal must be applied long enough for it to be recognized. The
longest instruction of the 8085 takes 18 clock periods. So, the interrupt signal must be
applied for at least 17.5 clock periods. This decides the minimum pulse width for the
interrupt signal.
The maximum pulse width for the interrupt signal is decided by the condition that the
interrupt signal must not be recognized once again. This is under the control of the
programmer.