Open In App

Difference between ISR and Function Call

Last Updated : 27 Apr, 2023
Like Article

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 


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


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

An ISR (Interrupt Service Routine) and a function call are both mechanisms used in software programming, but they serve different purposes.

An ISR is a special type of function that is executed in response to a hardware interrupt. When an interrupt occurs, the processor temporarily stops executing the main program and jumps to the ISR to handle the interrupt. ISRs are typically used to handle time-critical tasks or events, such as input/output operations, hardware timers, or user inputs.

On the other hand, a function call is a normal call to a function from within a program. A function call is used to execute a block of code that performs a specific task or operation. Function calls can be made at any point during program execution, and they can be called from multiple locations within the program.

Here are some key differences between ISR and function call:

  1. Execution: ISRs are executed in response to a hardware interrupt, whereas function calls are executed when they are called from within the program.
  2. Timing: ISRs are typically time-critical and need to be executed quickly to ensure proper system operation, while function calls are not time-critical and can be executed at any time.
  3. Context: When an ISR is executed, the processor is in a special context and interrupts are disabled. This means that the ISR must execute quickly and must not perform operations that can cause other interrupts to be missed. In contrast, function calls execute in the normal program context and can perform any operation.
  4. Return: ISRs typically do not return a value, while function calls can return a value to the caller.

Overall, the choice between an ISR and a function call depends on the specific requirements of the system and the task that needs to be performed. If a time-critical operation needs to be performed in response to a hardware interrupt, an ISR may be the best choice. If a normal operation needs to be performed, a function call may be more appropriate.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads