Lecture 1 8086 Interrupt
Lecture 1 8086 Interrupt
Polling and interrupts are two different mechanisms used in computer systems to help facilitate the communication and synchronization between devices. Polling involves
The primary distinction between an interrupt and polling lies in the communication between the CPU
and the system. With an interrupt, the system signals the CPU when it requires attention. In contrast,
during polling, the CPU continuously checks the system's status to determine if it needs to intervene.
Interrupts:
An interrupt is a signal that alerts the CPU to handle a specific task immediately. The device indicates to
the CPU that it needs its attention. When an interrupt occurs, the CPU typically suspends its current
task, handles the interrupt, and then resumes the previously paused task.
Polling:
Polling is a method where the CPU continuously checks if a system needs its attention. It's a consistent
process to ensure that the system is operating efficiently.
1. In an interrupt, the device signals the CPU In polling, the CPU continuously checks
when it needs attention. if the device needs attention.
4. It can occur at any given time. The CPU polls the system at specific
intervals.
The following image shows the types of interrupts we have in a 8086 microprocessor −
Hardware Interrupts
Hardware interrupt is caused by any peripheral device by sending a signal through a specified pin to
the microprocessor.
The 8086 has two hardware interrupt pins, i.e. NMI and INTR. NMI is a non-maskable interrupt and
INTR is a maskable interrupt having lower priority. One more interrupt pin associated is INTA called
interrupt acknowledge.
NMI
It is a single non-maskable interrupt pin - , ( having higher priority than the maskable interrupt
request pin ( - 3 1 and it is of type 2 interrupt.
COMPLETE CURRENT
INSTRUCTION
YES
INTERNAL
INTERRUPT?
NO
YES
NMI
NO
YES 1
ACKNOWLEDGE READ TYPE
INTR IF
INTERRUPT NUMBER
NO 0
1 COMPLET CURRENT
TF INSTRUCTION
0
CLEAR IF & TF
PUSH CS & IP
CALL INTERRUPT
SERVICE ROUTINE
EXECUTE USER
INTERRUPT ROUTINE
POP IP & CS
The user defines the function of the external hardware, software, and non
maskable interrupt. For instance, hardware interrupts are often assigned to devices
such as the keyboard, printer, and timers. On the other hand, the functions of the
internal interrupts and reset are not user defined. They perform dedicated system
functions. An example of a high-priority service routine that should not be
interrupted is that for a power failure. Once initiated, this routine should be quickly
run to completion to assure that the microcomputer goes through an orderly power-
down. A keyboard should also be assigned to a high-priority interrupt. This will
assure that the keyboard buffer does not get full and lock out additional entries. On
the other hand, devices such as the floppy disk or hard disk controller are typically
assigned to a lower priority level.
An address pointer table is used to link the interrupt type numbers to the
locations of their service routines in the program-storage memory. Figure below
shows a map of the pointer table in the memory of the 8086 microcomputer.
Example:
At what address are CS50 and IP50 stored in memory?
Solution:
Address= 4 × 50 = 200
and expressing it as a hexadecimal number results in
Address= C816
Interrupt Instructions
STI enables the external interrupt request (INTR) input for operation by
setting IF, while CLI disable the external interrupt input by resetting IF.
IRET instruction must be included at the end of each interrupt service routine.
When an interrupt request has been recognized on the NMI pin, the 8086
initiate type 2 interrupt (CS2:IP2).
When an interrupt request has been recognized on the INTR pin, then o If
IF= 0 then the interrupt request is ignored.
If IF= 1 then 8086
4. respond with two pulses at INTA during interrupt acknowledge bus cycle .
The first pulse signals the external circuitry that the interrupt request has
been acknowledged and to prepare to sent the number to the 8086.
The second pulse tells the external circuitry to put the type number on the
data bus.
RESET :
The reset input of the 8086 MPU provides a hardware means for initializing
the microcomputer.
After reset the MPU start execution at address:
85
CS : IP = FFFFH : 0000H
The INTR interrupt is activated by an I/O port. If the interrupt is enabled and NMI is disabled, then
the microprocessor first completes the current execution and sends ‘0’ on INTA pin twice. The first ‘0’
means INTA informs the external device to get ready and during the second ‘0’ the microprocessor
receives the 8 bit, say X, from the programmable interrupt controller.
Flag register value, CS value of the return address and IP value of the return address are pushed
on to the stack.
Software Interrupts
Some instructions are inserted at the desired position into the program to create interrupts. These
interrupt instructions can be used to test the working of various interrupt handlers. It includes −
CS value of the return address and IP value of the return address are pushed on to the stack.
The starting address for type0 interrupt is 000000H, for type1 interrupt is 00004H similarly for type2
is 00008H and ……so on. The first five pointers are dedicated interrupt pointers. i.e. −
The interrupts from Type 5 to Type 31 are reserved for other advanced microprocessors, and
interrupts from 32 to Type 255 are available for hardware and software interrupts.
INT 3-Break Point Interrupt Instruction
It is a 1-byte instruction having op-code is CCH. These instructions are inserted into the program so
that when the processor reaches there, then it stops the normal execution of program and follows the
break-point procedure.
CS value of the return address and IP value of the return address are pushed on to the stack.
CS value of the return address and IP value of the return address are pushed on to the stack.
BOUND:
Example: BOUND AX, Data ; Compares AX with Data
AX is compared with DATA and DATA+1; if less than an interrupt occurs.
AX is compared with DATA+2 and DATA+3; if greater than an interrupt occurs.
* After the execution of each instruction, the microprocessor determines whether an interrupt is
active by checking, in order:
If one or more of these conditions are present, then the microprocessor executes the
steps described above in "Interrupt response sequence".
Hardware Interrupts
• The INTR pin must be externally decoded to select a vector.
• Any vector is possible, but the interrupt vectors between 20H and
FFH are usually used (Intel reserves vectors between 00H and
1FH).
• INTA is an output of the microprocessor to signal the external
decoder to place the interrupt number on data bus connections D7-
D0.
Timing diagram of the handshake (2x INTA cycles) [1]
Examples of Hardware Interrupts :
1) Simpliest method of generating an interrupt vector:
vcc
gnd
3) Handling more than one IRQ:
If any of IRQx goes low, the NAND goes low requesting an interrupt.
Note that if more than one IRQ goes low, a unique interrupt vector is generated and
an interrupt priority needs to be defined.
o The Interrupt Vector table must be expanded to accommodate this.
Handling more than one interrupt :-
• If several INTR are generated from different peripherals
simultaneously is necessary to decide their priority and send the
INTA signal only to the highest priority peripheral.
• Two different methods can be used to establish the priority of
interrupt requests from different peripherals
1. Polling and daisy chaining
2. Interrupt priority management hardware
Example: a single
8259A connected in the
8086 [1]
• /CS must be decoded.
Other connections are
direct to micro
• Programmable IR
priority (defult: IR0
highest … IR7 lowest)
Adress decoder
Using 74LS138 address decoder:
In 8088, M/IO signal is represented by IO/M signal, therefore this signal is connected to G (active high)
signal of decoder to interface 8259A in I/O mapped I/O mode.
The 74LS138 address decoder will assert the CS input of the 8259 when an I/O base address is FFF0H or FFF2H on the address bus.
The A0 input of the 8259A is used to select one of the two internal addresses in the device.
A0 of the 8259A is connected to system line Al. So the system addresses for the two internal addresses are FFF0H and FFF2H.
The data lines of an 8259 are connected to the lower half of the system data bus; because the 8086 expects to receive interrupt types on
these lower eight data lines.
RD and WR signals are connected to the system RD and WR lines.
The interrupt request signal INT from the 8259 is connected to the INTR input of the 8086 and INTA from the 8086 is connected to
INTA on the 8259A.
As we are using single 8259 in the system SP/EN pin is tied high and CAS0-CAS2 lines are left open.
The eight IR inputs are available for interrupt signals.
Cascading :
The 8259 can be easily interconnected to get multiple interrupts.
Fig below shows how 8259 can be connected in the cascade mode.
In cascade mode one 8259 is configured in Master mode and other should be configured in the Slave mode.
Each slave 8259 is identified by the number which is assigned as a part of its initialization.
Since the 8086 has only one INTR input, only one of the 8259 INT pins is connected to the 8086 INTR pin.
The 8259 connected directly into the 8086 INTR pm is referred as the master.
Each 8259A has its own addresses so that command words can be written to it and status bytes read from it.
The INT pins from other 8259 are connected to the IR inputs of the master 8259.
The cascade pins CAS0 to CAS2 are connected from the master to the corresponding pins of the slave.
For the master these pins function as outputs, and for the slave these pins function as inputs.
The SP/EN signal is tied high for the master. However it is grounded for the slave.
Address for 8259s :
If the interrupt is unmasked and its priority is higher than any other interrupt level being serviced in the slave, then the slave will send
If that IR input of the master is unmasked and if that input is a higher priority than any other IR inputs currently being serviced, then
the master will send an INT signal to the 8086 INTR input.
If the INTR interrupt is enabled, the 8086 will go through its INTR interrupt procedure and sends out two INTA pulses to both the
The slave ignores the first interrupt acknowledge pulse but the master outputs a 3-bit slave identification number on the CAS0-CAS2
lines.
Sending the 3-bit ID number enables the slave. When the slave receives the second INTA pulse from the 8086, the slave will send the
If an interrupt signal is applied directly to one of the IR inputs of the master, the master will send the desired interrupt type to the 8086