This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Is it safe to save just part of registers in interrupt/exception handler?
- From: Ian Lance Taylor <iant at google dot com>
- To: "PRC" <panruochen at gmail dot com>
- Cc: "gcc-help" <gcc-help at gcc dot gnu dot org>
- Date: Fri, 13 Jun 2008 07:05:46 -0700
- Subject: Re: Is it safe to save just part of registers in interrupt/exception handler?
- References: <200806132107278789360@gmail.com>
"PRC" <panruochen@gmail.com> writes:
> 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?
In general, yes.
Ian