Lecture 12
Lecture 12
Interrupts
An interrupt is an external or internal event that interrupts the
microprocessor to inform it that a device needs its service.
2
Lecture 12
Interrupt Vectors (Real mode)
4*X Type X
0008 Type 2
0004 Type 1
0000 Type 0
3
Lecture 12
Interrupt Vectors
Table
(Real mode)
4
Interrupt Vectors Table
(Protected Mode)
5
Interrupt Vectors Table
(Protected Mode)
In order to find the interrupt services address, it is required to find
the start address of the code segment where interrupt services
resides. the segment selector in interrupt descriptor is used to index
into GDT/LDT. Using base address in GDT/LDT and the offset in
interrupt descriptor, the start of the interrupt service can be
allocated.
6
Lecture 12
Interrupts
Type 0 to Type 32 have predefined functions.
Type 0: invokes by when there is an attempt to divide a number by zero or
result from a division overflows
Type 1: specifically for implementation of single-stepping instructions for
program tracing. The trap flag (TF), must be set to 1. After execution of each
instruction, microprocessor jumps to physical location 00004 to fetch CS:IP
of the interrupt service routine.
Type 2: for NMI. When the NMI pin is activated by a high (5V) signal, the
CPU jumps to physical memory location 00008 to fetch the CS:IP of the ISR
routine associated with NMI.
INT 03: for the implementation of breakpoints in software engineering. A
breakpoint is used to examine CPU and memory after the execution of a
group of instructions.
Type 4: (Interrupt on Overflow) instruction. If instruction INTO is placed
after a signed number arithmetic or logic operation such as IMUL or ADD,
the CPU will activate Type 4 if OF = 1. If OF = 0, INTO is bypassed, acting
as a NOP (no operation) instruction. 7
Lecture 12 Interrupts
8
Lecture 12
The physical addresses for INT 12h are 00048-00048h since 4x12h= 48H
Software interrupts
Software interrupts are triggered with the INT instruction and
IRET
INT does the following:
Pushes flag register (PUSHF)
Pushes the current CS and IP
Far jumps to [0000:(4*Interrupt vector type)]
Usually clears the interrupt flag disabling the interrupt system
IRET does the following
Pops flag register
Performs a far return
9
Lecture 12
10
Lecture 12
Conditional:
INTO (type 4): on Overflow (the OF flag bit)
BOUND (type 5): on the result of comparing the contents of a
register with the contents of two successive words in memory,
e.g. BOUND AX, DATA
Causes interrupt type 5 if AX contents are outside the range
specified by the 4 bytes
i.e., [AX] < {[DATA], [DATA+1]} or [AX] > {[DATA+2],
[DATA+3]}
11
Lecture 12
Unconditional:
INT n: Executes the interrupt with the vector type n
Instruction takes 2 bytes: a byte for the opcode and a byte for n
e.g. INT 80H Start of the 4-byte vector address = 4 x 80H =
200H (200H – 203H)
INT 3: is a special case of INT n which fits into one byte
only. Useful in inserting a break point in the software for
debugging purposes
12
Lecture 12
Hardware interrupts
Hardware interrupt are triggered with INT or NMI signals
INTR is a MPU input signal, which can be masked & unmasked
through use CLI and STI.
NMI (Non-Maskable Interrupt), is an input signal into the MPU,
cannot be masked and unmasked. Power failure interrupts to
processor (NMI).
Interrupt enabling/disabling
14
Lecture 12
There are typically two INTA pulses generated for the following reasons:
The first INTA pulse informs the interrupting device that the
processor is ready to receive the Interrupt Vector Type Number
The second INTA pulse is generated by the processor to latch the
Interrupt Vector Type Number from the data bus.
15
Lecture 12
16
Lecture 12
1. Additional NAND for 7 interrupts
17
Lecture 12
18
Lecture 12
0
1
2
Interrupt outputs
3
from peripheral
4
devices
8259 5
PIC 6
7
INTR
INTA 8086
INT#
19
Lecture 12
Pin Diagram of 8259
20
Lecture 12
Pin Diagram of 8259
21