There are certain assumptions that the compiler makes about the IRP and AMR control registers. The assumptions should be enforced in all programs and are as follows:
- The AMR must be set to 0 upon calling or returning from a function. A function does not have to save and restore the AMR, but must ensure that the AMR is 0 before returning.
- The AMR must be set to 0 when interrupts are enabled, or the SAVE_AMR and RESTORE_AMR macros should be used in all interrupts (see Section 8.7.3).
- The IRP can be safely modified only when interrupts are disabled.
- The IRP's value must be saved and restored if you use the IRP as a temporary register.