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

5.1 Basics

5.2 Address Sizes

5.2.1 32-Bit Absolute

5.2.2 64-Bit Absolute

5.2.3 44-Bit Absolute

5.2.4 64-Bit with 13-Bit PIC

5.2.5 64-Bit With 32-Bit PIC

5.3 Global Object Table (GOT) Code Models

5.4 Thread Local Storage (TLS) Code Models

5.4.1 Local Executable Code Model

5.4.2 Initial Executable Code Model

5.4.3 Local Dynamic TLS Code Model

5.4.4 General Dynamic TLS Code Model

6.  Writing Functions -- The SPARC ABI

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

5.1 Basics

When compiling a simple C program like:

int sum = 0;
void add(int a)
{
   sum += a;
}

the kind of code used to access the variable sum is different for different code models. All the code models need a way to create the address for sum so that the address can be used to load or store the value. Different code models use different methods for creating an address.

There are two basic kinds of code models, absolute and position independent. Absolute code models create an address that is a constant, so that the variable cannot be moved without changing the code. Position independent code models create an address that is more movable and can be decided at run-time. Position independent code (PIC) is recommended and sometimes required for creating shared objects. The dynamic linker (ld.so) determines the location of the shared object at run-time and finalizes the position independent address. See the Oracle Solaris Linkers and Libraries Guide for more info on this topic.