Compiler interrupt flag
Some time ago I noticed an extra couple of instructions that are added automatically by XC8 compiler for the interrupt function:
void interrupt ISR (void)
bsf 126,0 ;set compiler interrupt flag (level 1)
bcf 126,0 ;clear compiler interrupt flag (level 1)
There is no mention to this behavior in the manual.
It sets a flag at address 0x7E (common memory in this example using PIC16F18346)
Does anyone know what is the purpose of this flag?
I've never seen it being used, it's just set at the ISR beginning and cleared before "retfie".
I've been working in an application that needed the minimal interrupt latency, so this extra instruction was a candidate for optimization (Yes, I needed every little optimization, I had to write to one port in reaction to the ISR in less than 1us, 6 instructions was my target: 4 lattency, movf and movwf using common memory @32Mhz).
I had to do this to avoid the extra instructions:
void ISR (void) __at(0x0004)
And add a call after the main loop to stop the compiler from removing this "unused" function.
The problem with this is that:
Compiler thinks no interrupt is being used.
Compiler thinks it's free to reuse any temporary variable used in the interrupt function for any other function.
In my case, these were not big problems, because the code used no temporary variables and was mainly inline asm.
Does anyone know a way to avoid the use of this special compiler interrupt flag (using C)?