Interrupts are used by computer systems to handle events that require immediate attention from the processor. Interrupts can be classified into two types: vectored and non-vectored.
A vectored interrupt is where the CPU actually knows the address of the interrupt service routine in advance. All it needs is that the interrupting device sends its unique vector through a data bus and through its I/O interface to the CPU. The CPU takes this vector, checks an interrupt table in memory and then carries out the correct ISR for that device. Therefore, the vectored interrupt allows the CPU to be able to know that ISR to carry out in software (memory).
A non–vectored interrupt is where the interrupting device never sends an interrupt vector. An interrupt is received by the CPU and it jumps the program counter to a fixed address in hardware. This is typically a hard coded ISR which is device agnostic. The CPU crucially does not know which device caused the interrupt without polling each O/I interface in a loop and checking the status register of each I/O interface to find the one with status “interrupt created”.
- Devices that use vectored interrupts are assigned an interrupt vector. This is a number that identifies a particular interrupt handler. The ISR address of this interrupts is fixed and is known to CPU.
- When the device interrupts the CPU branches to the particular ISR.
- The microprocessor jumps to the specific service routine.
- When the microprocessor executes the call instruction, it saves the address of the next instruction on the stack.
- At the end of the service routine, the RET instruction returns the execution to where the program was interrupted.
- All 8051 interrupts are vectored interrupts.
- Non-vectored interrupt is an interrupt that has a common ISR, which is common to all non-vectored interrupts in the system. Address of this common ISR is known to the CPU.
- The interrupts which don’t have fixed memory location for transfer of control from normal execution.
- The address of the memory is sent along with the interrupt.
- The CPU crucially does not know which device caused the interrupt without polling each I/O interface in a loop.
- Once the interrupt occurs, the system must determine which device, of all the devices associated actually interrupted.
- Handling mechanism: Vectored interrupts are handled by a dedicated interrupt vector table, which contains the addresses of the interrupt handlers for each device. Non-vectored interrupts, use a single interrupt handler that must identify the source of the interrupt.
- Identification of source: In a vectored interrupt system, the interrupt controller automatically identifies the source of the interrupt and routes it to the appropriate interrupt handler. In non-vectored systems, the interrupt handler must use a polling mechanism to determine the source of the interrupt.
- Response time: Vectored interrupts have a faster response time than non-vectored interrupts, as the system can quickly identify and route the interrupt to the appropriate handler without the need for polling.
- Complexity: Vectored interrupts are more complex than non-vectored interrupts, as they require a dedicated interrupt vector table and additional hardware for routing interrupts. Non-vectored interrupts are simpler, as they only require a single interrupt handler.
- Flexibility: Non-vectored interrupts are more flexible than vectored interrupts, as they can be used with a wide range of devices and don’t require specific interrupt handling mechanisms. Vectored interrupts, on the other hand, are optimized for specific devices and require specific interrupt handling mechanisms.
- Debugging: Debugging vectored interrupts can be more difficult than debugging non-vectored interrupts, as there are multiple interrupt handlers to manage and potential conflicts to resolve. Non-vectored interrupts are simpler to debug, as there is only one interrupt handler to manage.