JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
SPARC Assembly Language Reference Manual     Oracle Solaris 11.1 Information Library
search filter icon
search icon

Document Information

Preface

1.  SPARC Assembler Syntax

2.  Executable and Linking Format

3.  Directives and Pseudo-Operations

4.  Creating Data in Assembler

5.  SPARC Code Models

6.  Writing Functions -- The SPARC ABI

6.1 Anatomy of a C Function

6.2 Register Usage

6.3 Parameter Passing

6.4 Functions Returning Values

6.4.1 Limitations for 32-Bit Code

6.4.2 Limitations for Both 32-Bit and 64-Bit Code

6.4.3 Additional Information

7.  Assembler Inline Functions and __asm Code

A.  Using the Assembler Command Line

B.  A Sample Assembler Program

C.  SPARC Instruction Sets and Mnemonics

Index

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.