The Intel 8086 Microprocessor
The Intel 8086 Microprocessor
LECTURE - 6
Abdullah Al Noman
Lecturer
Computer Science and Engineering Department
Shahjalal University of Science and Technology
8086 Interrupt System
8086 INTERRUPT SYSTEM
o The 8086 interrupts can be classified into three types. These are
1. Predefined interrupts
• These interrupts are predefined by the manufacturer and serve specific
functions.
• Each interrupt has a different ISR (interrupt service routine) which has to be defined
previously.
• The interrupt vector addresses for all the 8086 interrupts are determined from a table
stored in locations 00000H through 003FFH.
• The starting addresses for the service routines for the interrupts are obtained by the
8086 using this table.
• Four bytes of the table are assigned to each interrupt: two bytes for IP and two bytes for
CS.
• The 8086 assigns every interrupt a type code for identifying the interrupt.
• There are 256 type codes associated with the 256 table entries.
• Each entry consists of two word addresses, one for storing the IP contents and the other
for storing the CS contents.
• Each 8086 interrupt physical address vector is 20 bits wide and is computed from the
16-bit contents of IP and CS.
• How will the microprocessor know which interrupt service routine to run from this
interrupt number?
8086 INTERRUPT SYSTEM
• For example, for the interrupt type n (instruction INT n), the table address for 𝐼𝑃 =
4 ∗ 𝑛 and the table address for 𝐶𝑆 = (4 ∗ 𝑛) + 2.
• For servicing the 8086's non-maskable interrupt (NMI pin), the 8086 assigns the type
code 2 to this interrupt. The 8086 automatically executes the INT 2 instruction
internally to obtain the interrupt address vector as follows:
• The 8086 loads the values of IP and CS from the 20-bit physical addresses 00008H and
0000AH in the pointer table. The user must store the desired 16-bit values of IP and CS
in these locations. Similarly, the IP and CS values for other interrupts are calculated.
8086 INTERRUPT SYSTEM
• In response to an interrupt, the 8086 pushes flags, CS, and IP onto the stack, clears TF
and IF flags and then loads IP and CS from the pointer table using the type code.
• Interrupt service routines must be terminated with the IRET (Interrupt Return)
instruction which pops the top three stack words into IP, CS, and flags, thus returning to
the right place in the main program.
• The user may also imitate these interrupts through hardware or software.
• If a predefined interrupt is not used in a system, the user may assign some other
function to the associated type.
DIVISION BY ZERO (TYPE 0)
• When the TF (TRAP/TRACE flag) is set by an instruction, the 8086 goes into the
single step mode. The TF can be set to one as follows:
• Note that in the above [BP + 0] rather than [BP] is used since BP cannot be used
without displacement.
• Once TF is set to one, the 8086 automatically generates a TYPE 1 interrupt after
execution of each instruction. The user can write a service routine at the interrupt
address vector to display memory locations and/or register to debug a program. Single
step is non-maskable and cannot be enabled by STI (enable interrupt) or disabled by
CLI (disable interrupt) instruction.
NONMASKABLE INTERRUPT PIN (TYPE 2)
• It is edge triggered (LOW to HIGH) and must be active for two clock cycles to
guarantee recognition.
• The 8086 obtains the interrupt vector address by automatically executing the INT 2
(type 2) instruction internally.
BREAKPOINT-INTERRUPT (TYPE 3)
• The user inserts the one-byte instruction INT 3 into a program by replacing an
instruction.
• This interrupt occurs if the overflow flag (OF) is set and the INTO or INT 4 instruction
is executed.
• The overflow flag is affected, for example, after execution of signed arithmetic such as
IMUL (signed multiplication) instruction.
• The user can execute the INTO instruction after the IMUL.
• If there is an overflow, an error service routine written by the user at the type 4 interrupt
address vector is executed.
USER-DEFINED SOFTWARE INTERRUPTS
• The user can generate an interrupt by executing a two-byte interrupt instruction INT n.
• The INT n instruction is not maskable by the interrupt enable flag (IF).
• The INT n instruction can be used to test an interrupt service routine for hardware
(external) interrupts.
• If predefined interrupt is not used in a system, the associated type code can be utilized
with the INT n instruction to generate software (internal) interrupts. So, type codes 0 to
255 can be used.
• Example: On board.
USER-DEFINED HARDWARE INTERRUPTS
• An ISR should also be written for hardware interrupts. But the difference is that this
hardware interrupt will never be called like the following.
INT 21h
• Since it is a hardware interrupt, the device that is connected to the microprocessor will
call this interrupt.
• Interrupt numbers up to 32 cannot be used for hardware interrupts. But all can be used
for software interrupts.
USER-DEFINED HARDWARE INTERRUPTS
• Hardware interrupts can be many because many hardware can be connected at once.
But how does the microprocessor know which hardware interrupt to activate?
USER-DEFINED HARDWARE INTERRUPTS