Skip to content
Related Articles

Related Articles

Improve Article

Difference between ISR and Function Call

  • Last Updated : 16 Jun, 2021

Interrupt :

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

Interrupt handling mechanism

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.

Function :



  • 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 :

Sl. No.

Interrupt service routine(ISR) 

Function call 

1.

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.

2.

  • The ISR address is written inside the interrupt vector table.
  • For example – 
    In the case of 8086, the first 1KB of memory, address 00000 H … 003FF H, is reserved for the IVT.
  • The ISR address for each interrupt is fixed.
The address of the subroutine is written inside the instructions which is written in the main program code.  

3.

The address of the ISR is determined by the hardware.The address of the subroutine is written inside the main program.

4.



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

5.             

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.
The collection of all status bit conditions in a microprocessor is called PSW(program status word).

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 

  • The AC register can be used for a single input parameter and a single output parameter. In computers with multiple processor registers, more parameters can be passed this way.
  • Another way to pass data to a subroutine is through the memory.

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :