Is it safe to save just part of registers in interrupt/exception handler?

Fri Jun 13 13:08:00 GMT 2008

Hi All,

The MIPS ABI document says:
For non-leaf function,$31 must be saved.  If any of
$16..$23 or$29..$31 is changed within the called function, it must be saved
in the stack frame before use and restored from the stack frame before re-
turn from the function. 

My interrupt/exception handler contains two parts: one written in assembly
and the other written in C. The ASM handler does some simple work like
saving status, epc and gerneral registers and then jumps/calls to the C handler
to do more complex work. Since MIPS ABI guarantees $16~$23 and $29~$31 are saved
in C functions if they are used, is it safe to save only those registers except $16~$23 and $29~$31 in ASM handler?

Best regards
June 13, 2008

More information about the Gcc-help mailing list