5.24 __save_interrupt Intrinsic Function

The IAR __save_interrupt intrinsic function saves the interrupt flag so that it may later be used by the __restore_interrupt intrinsic function.

Suggested Replacement

There is no equivalent MPLAB XC8 built-in function, but the SREG registers can be updated with plain C code.

Use code that copies the interrupt bit within the SREG register into an ordinary variable.

Caveats

None

Examples

Consider migrating IAR code such as:
unsigned char saved;

void foo(void) {
    saved = __save_interrupt();
    __disable_interrupt();
    /* Critical section goes here */
    __restore_interrupt(saved);
}
to MPLAB XC8 code similar to:
volatile unsigned char saved;

void foo(void) {
    saved = (SREG & 0x80);
    di();
    /* Critical section goes here */
    SREG |= saved;
}