SPARC Assembly Language Reference Manual

Exit Print View

Updated: July 2014
 
 

6.2 Register Usage

The input registers %i0 through %i7, and the local registers %l0 through %l7 are callee saves registers.In other words, to use them in an assembly function called from C code, they should be saved first and restored before returning. These registers are normally saved in the callee by executing a save instruction to change the register windows, and restored with the restore instruction or the return instruction at the end of the function. If you use the input or local registers within an assembly language function and call a C function, there is no need to save those registers before the call.

The output registers %o0 to %o7 are caller saves registers and are also used for parameter passing and return values. To use the output registers in an assembly language function, there is no need to save them before using them. If calling a C function from assembly language, any useful value in an output register should be saved before the call is made.

The global registers %g0-%g7 are more complicated. The %g0 register is always zero. The %g6 and %g7 are always reserved for the operating system, so assembly code should not modify them. The other global registers, %g1-%g5, are caller saves, and are usable by applications code. But note that %g1 and %g5 may be used in the program linkage table (PLT) or other interposition code, and thus cannot be used to pass parameters from caller to callee.