I am using 89v51RD2. my question is how to push an address of a function on to stack in C?? For the same how do I get address of a function?? Plz Help.
The easiest way to push the address of a function onto the stack is to call it, isn't it?
situation is, when i get last byte from external interrupt 0 den Function(); should get called. But Function(); also needs some information from external interrupt. Now the thing is, if I call that function in ISR then I wont get new byte from INT 0 that is why i need to push address of function(); on to the stack instead of address from where ISR got called.
So essentially you want the handler of a high-priority interrupt to trigger a low-priority interrupt so that its handler would complete the processing? Why don't you do just that, assuming your MCU supports multiple interrupt priorities?
Sounds like a task better accomplished in assembler, with a clear understanding about what's on the stack, and the implications of calling/returning on the processor context.
For call back examples, look at qsort(), pointers to functions, calling back with parameters.
a well known technique. I know of no '51 derivative that does not have, at least, 2 priorities
>>> on to the stack instead of address from where ISR got called.
Do you really want to modify(!) the return address on the stack? The return address back to "somewhere" in the main application? Because you write "instead" and not "in addition".
I would have understood if you wrote: "Want to push the address of an additional function, to which the RETI will jump, and the RET of that function will then return to the main application that was interrupted before".
Even this is not a good programming style, a stack overflow may occur.
It occur relatively frequent that someone believes that letting an interrupt return to some other place than where it happened will solve some problem.
WRONG
But having the ISR return to somewhere else is basically what an RTOS does. But it does it by switching to another stack at the same time.