| |||||
Technical Support Support Resources
Product Information | C51: INTERRUPT SERVICE ROUTINES LOCATED AT WRONG ADDRESSESInformation in this article applies to:
QUESTIONI've written a very simple program with a dummy ISR as follows:
void ISR (void) interrupt 0
{
}
void main (void)
{
while (1)
{
}
}
When I look at the map file, it appears that my ISR is located at the wrong address.
* * * * * * * C O D E M E M O R Y * * * * * * *
CODE 0000H 0003H ABSOLUTE
CODE 0003H 0003H ABSOLUTE
CODE 0006H 000CH UNIT ?C_C51STARTUP
CODE 0012H 0002H UNIT ?PR?MAIN?MAIN
CODE 0014H 0001H UNIT ?PR?ISR?MAIN
What's going on? Shouldn't the ISR (?PR?ISR?MAIN) be located at 0003h instead of 0006h? ANSWERThe code generated by the compiler is correct. When you create an interrupt service routine (in C), the compiler generates 2 code objects. The first object is the interrupt service routine. This routine is terminated with an IRET instruction. The interrupt service routine is relocatable and may be located anywhere in CODE memory. This is ?PR?ISR?MAIN in your example. The second object is the interrupt vector to LJMP to the interrupt routine. If you take a look at the code map (from the linker map file) you will notice that at address 0003h, there are 3 bytes that are marked as ABSOLUTE. This is the LJMP instruction that jumps to ?PR?ISR?MAIN in your example. Last Reviewed: Tuesday, May 29, 2001 | ||||
| |||||