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.
Thanks Per. I'm currently in the learning stage. Is calling it from assembler not good?
thanks again gilmar
"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!
Thank you guys for the help. It is much clearer now.
regards gilmar
Check-out these resources:
http://www.8052.com/tutorial
www.8052.com/.../120112
http://www.keil.com/books/
Thanks Andrew. Do you know where can I find this "How to use Keil 8051 C Compiler, by Kim Hyoung tae"? It seems interesting to me.
Follow the link given on http://www.keil.com/books/8051books.asp ?