When CPU receives exception, Pre-processing by hardware Saving the current PC and PSW values in RAM (or in control registers in the case of the fast interrupt) and Reading of the vector Branching to the start of the exception handling routine is done.But, General purpose registers and control registers other than the PC and PSW that are to be used within the exception handling routine must be preserved on the stack by user program code at the start of the exception handling routine. Reverse is repeated by user code and hardware upon returning from exception. (Reference: Renesas Rx62n hardware manual, page 297, Chapter:Exceptions)
My question is where is this user code for context switching and how it is getting called?