Interrupts in 8086 Microprocessor

Last updated on May 9th, 2022 at 01:22 pm

In this post, we will build our concepts on the Interrupts in 8086 Microprocessor with the help of a set of questions and answers.

What is the function of an interrupt in a microprocessor?

An Interrupt is a condition that halts the microprocessor temporarily so that the microprocessor can work on a different task and then return to its previous task. Interrupt allows peripheral devices to access the microprocessor.

Whenever an interrupt occurs the processor completes the execution of the current instruction and starts the execution of an Interrupt Service Routine (ISR). ISR is a program that tells the processor what to do when the interrupt occurs. After the execution of ISR, control returns back to the main program where it was interrupted.

How does the 8086 return to the main program after completing the ISR of an interrupt?

In the 8086 microprocessor, the following tasks are performed if an interrupt has been requested:

  1. The value of the flag register is pushed into the stack. It means that first the value of SP (Stack Pointer) is decremented by 2 then the value of the flag register is pushed to the memory address of the stack segment.
  2. The value of starting memory address of CS (Code Segment) is pushed into the stack.
  3. The value of IP (Instruction Pointer) is pushed into the stack.
  4. IP is loaded from word location (Interrupt type) * 04.
  5. CS is loaded from the next word location.
  6. Interrupt flag (IF) and Trap flag (TF) are reset to 0 to disable the INTR interrupt and single step or trap interrupt respectively.

The following flow diagram shows the processing of an interrupt by the 8086.

flow diagram shows the processing of an interrupt by the 8086
flow diagram shows the processing of an interrupt by the 8086

How many interrupt types are present in the 8086 and how they are classified?

There are 256 interrupt types in the 8086. Among these, a few interrupt types are assigned for specific interrupts such as the divide-by-0 interrupt and the NMI interrupt. A few interrupt types are reserved by Intel for future expansion. The programmer is free to use the remaining interrupt types according to his /her requirement.

The following image shows the classification of interrupts that we have in the 8086 microprocessor.

The image shows the classification of interrupts that we have in the 8086 microprocessor.

This image shows the classification of interrupts that we have in the 8086 microprocessor.

What are the different kinds of hardware and software interrupts in 8086?

Hardware Interrupts

A 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 (NMI) having higher priority than the maskable interrupt request pin (INTR) and it is of type 2 interrupt.

When this interrupt is activated, these actions take place −

  • Completes the current instruction that is in progress.
  • Pushes the Flag register values onto the stack.
  • Pushes the CS (code segment) value and IP (instruction pointer) value of the return address onto the stack.
  • IP is loaded from the contents of the word location 00008H.
  • CS is loaded from the contents of the next word location 0000AH.
  • The interrupt flag and trap flag are reset to 0.

INTR

The INTR is a maskable interrupt because the microprocessor will be interrupted only if interrupts are enabled using set interrupt flag instruction. It should not be enabled using clear interrupt Flag instruction.

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 the 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.

These actions are taken by the microprocessor −

  • First completes the current instruction.
  • Activates INTA output and receives the interrupt type, say X.
  • Flag register value, CS value of the return address, and IP value of the return address are pushed onto the stack.
  • IP value is loaded from the contents of word location X × 4
  • CS is loaded from the contents of the next word location.
  • The interrupt flag and trap flag is reset to 0

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 −

INT- Interrupt instruction with type number

It is 2-byte instruction. The first byte provides the op-code and the second byte provides the interrupt type number. There are 256 interrupt types under this group.

Its execution includes the following steps −

  • The flag register value is pushed onto the stack.
  • CS value of the return address and IP value of the return address are pushed onto the stack.
  • IP is loaded from the contents of the word location ‘type number’ × 4
  • CS is loaded from the contents of the next word location.
  • Interrupt Flag and Trap Flag are reset to 0

The starting address for type 0 interrupt is 00000H, for type 1 interrupt is 00004H similarly for type 2 is 00008H, and ……so on. The first five interrupts are dedicated interrupt pointers. i.e. −

  • TYPE 0 interrupt represents division-by-zero situation.
  • TYPE 1 interrupt represents single-step execution during the debugging of a program.
  • TYPE 2 interrupt represents non-maskable NMI interrupt.
  • TYPE 3 interrupt represents break-point interrupt.
  • TYPE 4 interrupt represents overflow interrupt.

The interrupts from Type 5 to Type 31 are reserved for other advanced microprocessors, and interrupts from Type 32 to Type 255 are available for hardware and software interrupts.

Name the dedicated interrupts in the 8086 along with their functions.

INT 03 – BreakPoint Interrupt Instruction

It is a 1-byte instruction having op-code CCH. These instructions are inserted into the program so that when the processor reaches there, then it stops the normal execution of the program and follows the break-point procedure.

Its execution includes the following steps −

  • The flag register value is pushed onto the stack.
  • CS value of the return address and IP value of the return address are pushed onto the stack.
  • IP is loaded from the contents of the word location 3×4 = 0000CH
  • CS is loaded from the contents of the next word location.
  • Interrupt Flag and Trap Flag are reset to 0

INTO – Interrupt on overflow instruction

It is a 1-byte instruction and their mnemonic INTO. The op-code for this instruction is CEH. As the name suggests it is a conditional interrupt instruction, i.e. it is active only when the overflow flag is set to 1 and branches to the interrupt handler whose interrupt type number is 4. If the overflow flag is reset then, the execution continues to the next instruction.

Its execution includes the following steps −

  • Flag register values are pushed onto the stack.
  • CS value of the return address and IP value of the return address are pushed onto the stack.
  • IP is loaded from the contents of word location 4×4 = 00010H
  • CS is loaded from the contents of the next word location.
  • Interrupt flag and Trap flag are reset to 0

Type 00H or Divide-by-zero interrupt

Whenever the quotient from DIV or IDIV operation is too large to fit in the result register, the 8086 automatically generates a type0 interrupt.

Type 01H or Single Step interrupt

If the TF in the 8086 is set, the 8086 automatically generates a type1 interrupt after each instruction in the main program is executed. After executing the IRET instruction in the ISR, the 8086 again goes to execute the next instruction in the main program.

Type 02H or NMI interrupt

It is a single non-maskable interrupt pin (NMI) having higher priority than the maskable interrupt request pin (INTR) and it is of type 2 interrupt.

When this interrupt is activated, these actions take place −

  • Completes the current instruction that is in progress.
  • Pushes the Flag register values onto the stack.
  • Pushes the CS (code segment) value and IP (instruction pointer) value of the return address onto the stack.
  • IP is loaded from the contents of the word location 00008H.
  • CS is loaded from the contents of the next word location 0000AH.
  • The interrupt flag and trap flag are reset to 0.

Explain the interrupt structure of 8086 with its Interrupt Vector Table (IVT).

Interrupt Vector Table (IVT) on 8086 microprocessor

The 8086 microprocessor maintains an Interrupt vector table (IVT) which stores the information regarding the location of interrupt service routines (ISR) of various interrupts. In a very simple way, whenever an interrupt occurs, the memory location of ISR is determined using the vector table, and the program control branches to ISR after saving the flags and the program location (the content of the Instruction pointer and code segment register) in the stack.

The IVT can be up to 1kB starting from 00000H to 003FFH of the main memory. For each interrupt, the following is stored:

  • Code segment Register content (16-bit value)
  • Instruction pointer content (16-bit value)

Therefore the size for each interrupt vector is 4 bytes. 2 bytes (16 bits) for Code Segment (CS) and 2 bytes for Instruction Pointer (IP). These two determine the memory address, i.e. where the interrupt service routine (ISR) for the interrupt is located.

The total 256 interrupts may be represented (each in 4 bytes) in the vector table. These are identified as Type0 to Type255 interrupts. The external logic passes the vector/type number of the interrupt to the 8086 during the interrupt acknowledge bus cycle. The vector/type number is multiplied by 4 to get the memory location vector/type.

As an example, if the vector/type number of the interrupt is 32, its memory address in the vector table will be 32 X 4 = (128)10=00080H

The 8086 interrupt vector table is shown in the figure below:

The 8086 interrupt vector table is shown in figure below:
The 8086 interrupt vector table is shown in figure

Write the priority among the interrupts in the 8086.

The priority structure for various interrupts in the 8086 is as follows:

Interrupt Priority

  • Divide-by-zero, INT n and INTO Highest
  • NMI –
  • INTR –
  • Single Step Lowest

Author of this post

This post is co-authored by Professor Saraswati Saha, who is an assistant professor at RCCIIT, a renowned degree engineering college in India. Professor Saha teaches subjects related to digital electronics & microprocessors.

Scroll to top
error: physicsTeacher.in