Difference between ISR and Function Call
- An interrupt is a special type of condition that occurs during the working of a microprocessor.
- Microprocessor services the interrupt by executing a subroutine called interrupt service routine (ISR).
- The interrupt can be given to the processor by the external signal(i.e. on external pins of a Microprocessor) or as a software interrupt or by the condition produced by the program.
Interrupt handling mechanism :
- When an interrupt occurs, the processor first finishes the current instruction.
- It then suspends the current program and executes an ISR.
- For this, it pushes the value of PC (address of next instruction) into the stack.
- Now it loads the ISR address into PC and proceeds to execute the ISR.
- At the end of the ISR, it pops the return address from the stack and loads it back into PC.
- This is how the processor returns to the very next instruction in the program.
Example 1 –
I/O transfer by interrupt driven I/O
- If an I/O device which wants to perform a data transfer with the processor, must give an interrupt to the processor.
- An interrupt is a condition that makes the processor execute an ISR (Interrupt Service Routine).
- In the ISR, the processor will perform data transfer with the I/O device.
- Whenever a device wants to transfer data, it will interrupt the processor.
Example 2 –
Interrupt request by pressing the keyboard key,
- Instead of the processor checking all the time, whether a key is pressed, the keyboard interrupts the processor as when we press a key. In the ISR of the keyboard, which is a part of the keyboard driver software, the processor will read the data from the keyboard.
- A subroutine (procedure/Subroutine) is a set of instructions needed repeatedly by the program. It is stored as a subroutine and called from several places by the main program.
- In the case of an 8086 processor, a subroutine is invoked by a CALL instruction or and control returns by a RET instruction.
- It reduces the size of the program.
- Executes slow because time is wasted to push and pop the return address in the stack.
- It depends on the stack.
Difference between ISR and function call :
Interrupt service routine(ISR)
|The interrupt is usually initiated by an internal (i.e. divided by zero, register overflow etc.) or a external signal (i.e. external pins of) microprocessor rather than the execution of instructions(i.e. software interrupt). After storing the current status of the program (i.e. value of PC ,PSW ) in the stack, the ISR is executed. ISR performs different types of tasks depending on the device which interrupted or instructions written by a programmer(in the case of software interrupts).||The function call is invoked by execution of instructions, which perform the specific tasks, and also reduces the size of the program.|
|The address of the subroutine is written inside the instructions which is written in the main program code.|
|The address of the ISR is determined by the hardware.||The address of the subroutine is written inside the main program.|
|ISR is used for all general purpose tasks.|
For example –
If the paper in the printer is not present, then the interrupt is generated by the printer which executes an ISR(i.e. error message on the display).
|Function calls are made for program specific tasks(i.e. for application specific tasks).|
When an interrupt occurs during the execution of a current program, therefore, after execution of the current instruction, the processor executes ISR. After the execution of ISR, the processor must resume to program exactly as before the interrupt occurred. For this, the content of the PC, content of µP registers and the content of some status conditions is stored.
During the interrupt cycle, the contents of PC and PSW are pushed onto the stack. The branch address for the particular interrupt is then passed to PC and a new PSW is loaded into the status register.
The last instruction in the ISR is the return from interrupted instruction. When this instruction is executed, the old PSW and the return address are popped from the stack.
Here, only a PC is stored on the stack to get the address of the next instruction in the main program.
It is necessary for the subroutine to have access to data from the calling subroutine and to return results to that subroutine. Therefore, subroutine parameters and data linkage is done.
This can be done through
Please Login to comment...