Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

difference b/n function call and interrupt call

Status
Not open for further replies.

dev

Junior Member level 3
Joined
Feb 26, 2004
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
224


what happens when a function call is generated in the system.

and

what happens when a interrupt call is generated in the system

what is difference between these two?
 

interrupt call generated when an outside stimulus or signal come to an interrupt input of any uP. And the related interrupt rutin is run.

Function call is realized deleberately by the programmer in any part of the code. You write a function for a repeated part of code. And you call it when you need in the code instead of rewritting the repeated code. Besides This saves part in memory. Because the repeated code will not be repeated in the memory, instead the routin will go to the function part of the code in memory. After the function is run the program counter will turn back to the place in the original code
 

A function call is usually program generated.

An interrupt is usually generated by hardware.

for example: If you program in C, You call the function by making the function. There is the Main function and the Sub-functions. The sub functions are programmed by the programmer.

The interrupts however, are hardware specific. for example:
In a computer, The CPU is processing a program and running it. If you press a key on your keyboard, the keyboard then sets the keyboard interrupt to the cpu. Now the CPU can act on keypressed action.

The best way to sum up?
1. functions are created by programmers.
2. interrupts are physically designed into the hardware and utilized by other hardware.

Hope this helps
wa
 

Both functions eventually return to the place where they got called .But with the interrupt funtion .. the return instruction is RETI which clears the
source of interrupt .. otherwise it will be called over and over ..
In the case of the function the return is just RET...
 
Would say that one main difference is:

Function call happens in a predictive way...you know when you call it and why...

Interrupts can occur at any time and therefore the interrupt service routine needs some housekeeping to be done..otherwise it can overwrite any valuable information in registers, memory locations or periphals...
 

Hi

During function calls, there is no context change, so only the main registers of your CPU must be pushed into the stack. They are restored (poped) as the call returns.

During interrupt calls, the full context change, so all the registers are pushed into the stack and are restored or poped when interrupt call return. Furthermore, during interrupt calls, interrupt are masked, avoiding other interrupt to disturb the current interrupt routine. The purpose of the specific RETI or IRET instruction is to enable interrupt again after return from interrupt call.
 
The fucntion call can in some cases involve context chnage as well if let say it is OS fucntion call realized in form of software interrupt (see Linux OS calls ). So it is generally hardware and software dependent but function call without content change is most frequently used one .
If function declared inluine no actual fucntion call will be done , but function code will be explored in place where it is called . But again this is implementation defined .
 

    V

    Points: 2
    Helpful Answer Positive Rating
IRQ use RETI at the end of routine/function.
where normal function use RET.

RETI will enable the interrupt again. so next interrupt can come again.
 
I guess most of the answers are already here. I will just add few more and surmise it.

The entire base would be function call is predictive and interrupt is non predictive
Interrupt occurs from HW or SW. The HW interrupts are non predictive with two kinds as maskable and non-maskable.
SW interrupts are predictive and generally used for OS System calls. where as Function calls are predictive from the program execution point.

As Interrupts are abrupt entry, the entire context(All registers) is pushed to the stack by the processor. Where as function calls are planned and the calling process would deliberately push only the used registers and arguments to stack.

Another important point is that Function calls can return value and Interrupt calls cannot. This is because there is no return place predefined for a interrupt call.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top