Hi, Is it possible from startup.asm I can call the interrup service routine found in my C source file?
from my C source file:
void InterruptServiceRoutine (void) interrupt 7 //SMB { ... }
In my startup.asm:
... EXTRN CODE (InterruptServiceRoutine) ... ljmp InterruptServiceRoutine
Your response is greatly appreciated.
thanks gilmar
Yes, most processors are able to call ISR from assembler.
But the big question is why? Somehow, I think you are trying to solve a problem that has better solutions. Or solving a problem that doesn't need to be solved.
"most processors are able to call ISR from assembler"
An 8051 ISR needs to end with a RETI instruction - which is different from the RET instruction for a "normal" call: http://www.keil.com/support/man/docs/is51/is51_reti.htm http://www.keil.com/support/man/docs/is51/is51_ret.htm
RETI affects the interrupt hardware - so probably not a good idea to use it when the hardware is not in the right state for it...!
This is why the C51 compiler specifically prevents you from doing this:
"The compiler recognizes direct calls to interrupt functions and rejects them. It is pointless to call interrupt procedures directly, because exiting the procedure causes execution of the RETI instruction which affects the hardware interrupt system of the 8051 chip. Because no interrupt request on the part of the hardware existed, the effect of this instruction is indeterminate and usually fatal. Do not call an interrupt function indirectly through a function pointer" http://www.keil.com/support/man/docs/c51/c51_le_interruptfuncs.htm
"I think you are trying to solve a problem that has better solutions"
Indeed!
No! - See above!
View all questions in Keil forum