An interrupt service routine (ISR) is declared using the interrupt keyword.
{
...
}
n | Interrupt Vector | Interrupt Vector Address |
0 | RESET vector | 0x000000 |
1 | HIGH priority interrupts | 0x000008 |
2 | LOW priority interrupts | 0x000018 |
When generating assembly code for ISR the code generator places a GOTO instruction at the Interrupt Vector Address which points at the genetated ISR. This single GOTO instruction is part of an automatically generated interrupt entry point function. The actuall ISR code is placed as normally would in the code space. Upon interrupt request, the GOTO instruction is executed which jumps to the ISR code. When declaring interrupt functions as _naked this GOTO instruction is not generated. The whole interrupt functions is therefore placed at the Interrupt Vector Address of the specific interrupt. This is not a problem for the LOW priority interrupts, but it is a problem for the RESET and the HIGH priority interrupts because code may be written at the next interrupt's vector address and cause undeterminate program behaviour if that interrupt is raised.4.2
n may be omitted. This way a function is generated similar to an ISR, but it is not assigned to any interrupt.
When entering an interrupt, currently the PIC16 port automatically saves the following registers: