The interrupt procedure
In the 8085 microprocessor the interrupt service routine (ISR) is a crucial component that plays a significant role in interrupt handling. Here is a detailed explanation:
Introduction to interrupts in the 8085
An interrupt is a signal that causes the microprocessor to temporarily suspend execution of the current program and transfer control to a specific subroutine known as the interrupt service routine. This mechanism allows the microprocessor to respond promptly to external events or internal conditions. The 8085 microprocessor has five interrupt signals: TRAP, RST 7.5, RST 6.5, RST 5.5 and INTR.
How the interrupt service routine works
Interrupt generation
An external device or an internal event generates an interrupt signal. For example, a peripheral device such as a keyboard can send an interrupt signal to the 8085 when a key is pressed, indicating that it needs the microprocessor's attention.
Interrupt detection
The 8085 microprocessor continuously checks for interrupt signals on its interrupt pins. When it detects an interrupt signal and the interrupt is enabled (the interrupt enable flag is set), the microprocessor will respond to the interrupt.
Context saving
Before jumping to the ISR, the microprocessor saves the current program state, including the contents of the registers and the program counter. This is done so that, after the interrupt has been handled, the microprocessor can resume execution of the original program from the point where it was interrupted.
ISR vectoring
Each interrupt in the 8085 has a fixed memory location called the interrupt vector. When an interrupt is detected, the microprocessor jumps to the corresponding interrupt vector address. The ISR is located at this address. For example, the TRAP interrupt has the vector address 0024h.
ISR execution
Once the microprocessor reaches the ISR, it begins executing the ISR instructions. The ISR usually contains the code that handles the specific event that caused the interrupt. For example, if the interrupt was caused by keyboard input, the ISR can read the key code from the keyboard buffer and perform the appropriate action, such as storing the character in memory or displaying it on the screen.
Context restoration
After the ISR has completed its task, it restores the saved registers and program counter values. This is done using instructions such as POP in 8085 assembly language.
Return to the main program
The microprocessor then returns to the main program and continues execution from the point where it was interrupted.