Software and Hardware Interrupt Applications

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Interrupts:

1. An interrupt is a special condition that arises during the


working of a microprocessor. The microprocessor services
it by executing a subroutine called Interrupt Service
Routine (ISR).
2. There are three sources of interrupts for 8086:
3.Hardware interrupt-
These interrupts occur as signals on the external pins of
the microprocessor. 8086 has two pins to accept hardware
interrupts, NMI and INTR.

4.Software interrupt-
These interrupts are caused by writing the software
interrupt instruction INT n where ‘n’ can be any value from
0 to 255 (00H to FFH). Hence all 256 interrupts can be
invoked by software.

5. Error conditions (Exception or types)-


8086 is interrupted when some special conditions occur
while executing certain instructions in the program.
Example: An error in division automatically causes the INT
0 interrupt.
Interrupt Vector Table (IVT):

1. The interrupt vector (or interrupt pointer) table is the link


between an interrupt type code and the procedure that
has been designated to service interrupts associated
with that code. 8086 supports total 256 types i.e. 00H to
FFH.
2. For each type it has to reserve four bytes i.e. double word.
This double word pointer contains the address of the
procedure that is to service interrupts of that type.
3. The higher addressed word of the pointer contains the
base address of the segment containing the procedure.
This base address of the segment is normally referred as
NEW CS.
4. The lower addressed word contains the procedure’s offset
from the beginning of the segment. This offset is normally
referred as NEW IP.
5. Thus NEW CS: NEW IP provides NEW physical address
from where user ISR routine will start.
6. As for each type, four bytes (2 for NEW CS and 2 for NEW
IP) are required; therefore interrupt pointer table
occupies up to the first 1k bytes (i.e. 256 x 4 = 1024 bytes)
of low memory.
7. The total interrupt vector table is divided into three
groups namely,

A. Dedicated interrupts (INT 0…..INT 4)

B. Reserved interrupts (INT 5…..INT 31)

C. Available interrupts (INT 32…..INT 225)


A. Dedicated interrupts (INT 0…..INT 4):
1. INT 0 (Divide Error)-

o This interrupt occurs whenever there is division error


i.e. when the result of a division is too large to be
stored. This condition normally occurs when the
divisor is very small as compared to the dividend or
the divisor is zero.
o Its ISR address is stored at location 0 x 4 = 00000H in

the IVT.
2. INT 1 (Single Step)-

o The microprocessor executes this interrupt after


every instruction if the TF is set.
o It puts microprocessor in single stepping mode i.e.

the microprocessor pauses after executing every


instruction. This is very useful during debugging.
o Its ISR generally displays contents of all registers. Its

ISR address is stored at location 1 x 4 = 00004H in the


IVT.
3. INT 2 (Non mask-able Interrupt)-

o The microprocessor executes this ISR in response to


an interrupt on the NMI (Non mask-able Interrupt)
line.
o Its ISR address is stored at location 2 x 4 = 00008H in
the IVT.
4. INT 3 (Breakpoint Interrupt)-

o This interrupt is used to cause breakpoints in the


program. It is caused by writing the instruction INT
03H or simply INT.
o It is useful in debugging large programs where single

stepping is efficient.
o Its ISR is used to display the contents of all registers

on the screen. Its ISR address is stored at location 3 x


4 = 0000CH in the IVT.
5. INT 4 (Overflow Interrupt)-

o This interrupt occurs if the overflow flag is set and the


microprocessor executes the INTO (Interrupt on
Overflow) instruction.
o It is used to detect overflow error in signed arithmetic
operations.
o Its ISR address is stored at location 4 x 4 = 00010H in
the IVT.

B. Reserved interrupts (INT 5…..INT 31):

1. These levels are reserved by Intel to be used in higher


processors like 80386, Pentium etc. They are not available
to the user.

C. Available interrupts (INT 32…..INT 225):

1. These are user defined, software interrupts.


2. ISRs for these interrupts are written by the users to service
various user defined conditions.
3. These interrupts are invoked by writing the instruction INT
n. Its ISR address is obtained by the microprocessor from
location n x 4 in the IVT.

Hardware Interrupts:
1. NMI (Non mask-able interrupt)-

o This is a non-mask-able, edge triggered, high priority


interrupt.
o On receiving an interrupt on NMI line, the
microprocessor executes INT
o Microprocessor obtains the ISR address from location
2 x 4 = 00008H from the IVT.
o It reads 4 locations starting from this address to get
the values for IP and CS to execute the ISR.
o INTR-This is a mask-able, level triggered, low priority
interrupt.

Hardware Interrupt Applications


1.Simple Interrupt data input.

2. Counting Applications

3. Timing Applications.
Software Interrupt Applications
1. To test various ISPs. To insert break points in program for
debugging

2. To call BIOS procedures in an IBM PC type compute

Simple Interrupt Data Input:


One of the most common uses of interrupts is to relieve a CPU
of the burden of polling. To refresh your memory polling works
as follows. The strobe or data ready signal from some external
device is connected to an input port line on the microcomputer.
The microcomputer uses a program loop to read and test this
port line over and over until the data ready signal is found to be
asserted. The microcomputer then exits the polling loop and
reads in the data from the external device. The disadvantage of
polled input or output is that while the microcomputer is
polling the strobe or data ready signal, it cannot easily be doing
other tasks. I n this case the data ready or strobe signal is
connected to an interrupt input on the microcomputer. The
microcomputer then goes about doing its other tasks until it is
interrupted by a data ready signal from the external device. An
interrupt service procedure can read in or send out the desired
data in a few microseconds and return execution to the
interrupted program. The input and output operation then uses
only a small percentage of the microprocessors time.
Counting Applications:
As a simple example of the use of an interrupt input for
counting , suppose that we are using an 8086 to control a
printed circuit board making machine in our computerized
electronics factory. Further suppose that we want to detect
each finished board as it comes out of the machine and to
keep a count with the number of boards fed in. This way
we can determine if any boards were lost in the machine.
To do this count on an interrupt basis, all we have to do is
to detect when a board passes out of the machine and
send an interrupt signal to an interrupt input on the 8086.
The interrupt service procedure for that input can simply
increment the board count stored in a named memory
location. To detect a board coming out of the machine, we
use an infrared LED, a photoresistor and two conditioning
gates. The LED is positioned over the track where the
boards come out, and the photoresistor is positioned
below the track. When no board is between the LED and
the photoresistor, the light from the LED will strike the
photoresistor and turn it on. The collector of the
photoresistor will then be low, as will the NMI input on the
8086. When a board passes between the LED and
photoresistor, the light will not reach the photoresistor
and turn it on. The collector of the photoresistor will then
be low, as will the NMI input on the 8086.
Software Interrupt Applications:

The software interrupt instruction INT N can be used to test any


type of interrupt procedure. For example to test a type 64
interrupt procedure without the need for external hardware,
we can execute the instruction INT 64.

Another important use of software interrupts is to call Basic


Input Output System, or BIOS, procedures in an IBM PC-type
computer. These procedures in the system ROMS perform
specific input or output functions, such as reading a character
from the keyboard, writing some characters to the CRT, or
reading some information from a disk. To call one of these
procedures, you load any required parameters in some
specified registers and execute an INT N instruction. N in this
case is the interrupt type which vectors to the desired
procedure. Suppose that, as part of an assembly language
program that you are writing to run on an IBM PC type
computer, you want to send some characters to the printer.
The header for the INT 17H procedure from the IBM PC BIOS
listing. The DX, AH, and AL registers are used to pass the
required parameters to the procedure. The procedure is used
for two different operations: initializing the printer port and
sending a character to the printer. The operation performed by
the procedure is determined by the number passed to the
procedure in the AH register. AH=1 means initialize the printer
port, AH=0 means print the characters in AL, and AH=2 means
read the printer status and returned in AH. If an attempt to
print a character was not successful for some reason, such as
the printer not being turned on, not being selected, or being
busy, 01 is returned in AH. The main advantage of calling
procedures with software interrupts is that you don’t need to
worry about the absolute address where the procedure actually
resides or about trying to link the procedure into your program.
So at last every microcomputer system uses a variety of
interrupts and this is all about 8086 interrupts and applications.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy