5.9.4 Context Switching

The compiler will automatically link code into your project which saves the current status when an interrupt occurs and then restores this status when the interrupt returns.