Professional Documents
Culture Documents
Lecture # 12
Interrupts
CH 14
80X86 IBM PC and Compatible Computers
Assembly Language, Design, and Interfacing
CH9
8086 INTERRUPT from Fundamentals of Digital_ Logic_ and_
Microcomputer_ Design
Types of interrupt
P
POLLING
Microprocessor 2023 Raafat S
12/2/2022 Habeeb 3
Polling vs. Interrupt
instruction
Interrupt
request
P
INTERRUPT
Microprocessor 2023 Raafat S
12/2/2022 Habeeb 4
What is Interrupt
• In the 8086/88 there are a total of 256 interrupts: INT 00, INT 01, ...,
INT FF (sometimes called TYPEs ).
• When an interrupt is executed,
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R R R R OF DF IF TF SF ZF U AF U PF U CF
R = reserved
U = undefined
OF = overflow flag
DF = direction flag
IF = interrupt flag
TF = trap flag
SF = sign flag
ZF = zero flag
AF = auxiliary carry flag
PF = parity flag
CF = carry flag
7 Microprocessor 2023
Raafat S Habeeb
CE 444 Computer Interfacing
8 Microprocessor 2023
Mohamad Al Azawi
Raafat S Habeeb
8 alazawi@yu.edu.jo
Interrupt vector table
. . .
. . .
. . .
. . .
INTFF 003FC 0000:03FC
CS
00018 IP } INT 06
CS
00014 IP } INT 05
CS
00010 IP } INT 04 signed number overflow
CS
0000C IP } INT 03 breakpoint
CS
00008 IP } INT 02 NMI
CS
00004 IP } INT 01 single-step
CS
00000 IP } INT 00 divide error
CALL INT
• can jump to any location within • goes to a fixed memory location in the
the 1 megabyte address range of interrupt vector table to get the
the 8088/86 CPU, address of the interrupt service
routine.
• used by the programmer in the • externally activated hardware interrupt
sequence of instructions in the can come in at any time, requesting
program the attention of the CPU
• cannot be masked (disabled), • belonging to externally activated
hardware interrupts can be masked
• automatically saves only CS:IP • saves FR (flag register) in addition to
of the next instruction on the CS:IP of the next instruction.
stack
• At the end of subroutine that • the last instruction in the interrupt
has been called by the "CALL" service routine (ISR) for "INT nn" is
instruction, the RET is the last the instruction IRET (interrupt return).
instruction The difference is that RETF pops CS,
IP off the stack but the IRET pops off
the FR (flag register) in addition to CS
and IP.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R R R R OF DF IF TF SF ZF U AF U PF U CF
R = reserved
U = undefined
OF = overflow flag
DF = direction flag
IF = interrupt flag
TF = trap flag
SF = sign flag
ZF = zero flag
AF = auxiliary carry flag
PF = parity flag
CF = carry flag
• Recall that TF is D8 of the flag register. The analysis of the above two
programs is left to the you as a practice.
• To make TF =1, one simply uses the OR instruction in place of the
AND instruction above.
22 Microprocessor 2023 Raafat S Habeeb
INT 02 (nonmaskable interrupt)
Suppose that
» DATA1 =+64 =0100 0000
» DATA2 =+64 =0100 0000.
• The INT0 instruction will be executed and the 8086/88 will jump to
physical location 00010H, the memory location associated with INT
04.
• The carry from D6 to D7 causes the overflow flag to become 1.
• +64 01000000
• +64 01000000
• +128 1000 0000 OF=1 and the result is not +128
26 Microprocessor 2023 Raafat S Habeeb
• The above incorrect result causes OF to be set to 1.
• INT0 causes the CPU to perform "INT 04" and jump to
physical location 00010H of the vector table to get the
CS:IP of the service routine.
• Suppose that the data in the above program was DATA1
=+64 and DATA2 =+17.
• In that case, OF would become 0;
• the INT0 is not executed and acts simply as a NOP (no
operation) instruction.
Whenever the NMI pin is activated, the CPU will go to memory location 00008 to get the
address (CS:IP) of the interrupt service routine (ISR) associated with NMI.
Memory locations 00008,00009, 0000A, and 0000B contain the 4 bytes of CS:IP of the ISR
belonging to NMI.
In contrast, this is not the case for the other hardware pin, INTR. There is no specific
location in the vector table assigned to INTR.
The reason is that INTR is used to expand the number of hardware interrupts and should
be allowed to use any "INT nn" which has not been previously assigned.
The 8259 programmable interrupt controller (PIC) chip can be connected to
INTR to expand the number of hardware interrupts up to 64.
In the case of the IBM PC, one Intel 8259 PIC chip is used to add a total of 8 hardware
interrupts to the microprocessor.
IBM PC/AT, PS/2 80286, 80386, 80486, and Intel Pentium computers use two 8259 chips
to allow up to 16 hardware interrupts.
INTERRUPT PRIORITY
Divide Error ( Type0) 0 HIGHEST
NMI 1
INTR 2
Single –Step (Type 1) 3 LOWEST