Interrupt Functions In a fixed-point C compiler, interrupts can be handled directly using C functions. Each interrupt uses a fixed program name. As shown below c_int0 System reset interrupt c_int1 External interrupt 0 c_int2 External interrupt 1 c_int3 External interrupt 2 c_int4 Internal timer interrupt C_int5 Serial port receive interrupt c_int6 Serial port send interrupt c_int7 TDM port receive interrupt c_int8 TDM port send interrupt c_int9 External interrupt 3 When the above interrupt program is called, a subroutine named I$$SAVE is called first. This subroutine protects all registers. Similarly, when the function returns, a subroutine named 1$$REST is called to restore the protected registers. When writing interrupt programs in C language, the following points must be noted: (1) The word pointed to by SP (AR1) may be in use by the compiler, so it must be protected. (2) The interrupt mask and enable must be set by the programmer by modifying the IMR register using embedded assembly statements. This modification will not damage the C environment or C pointer. (3) Interrupt programs do not have parameter passing, and even if they are specified, they will be ignored. (4) Since all registers need to be protected when writing interrupt programs in C, the efficiency is not high. (5) When associating a program with an interrupt, a jump instruction must be placed at the corresponding interrupt vector. This function can be achieved by using the .sect assembly instruction to create a simple jump instruction table. (6) In assembly language, note that a hyphen must be added before the interrupt program name. For example, c_int1 in C language is _c_int1 in assembly language. (7) Interrupt programs or programs that need to be called in interrupt programs cannot be compiled with the _oe option for optimization.