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

4.1 Examples

5.  SPARC Code Models

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

4.1 Examples

Here are some examples of writing declarations and definitions for various kinds of data types.

Example 4-1 Examples

The following demonstrates the use of the .word, .half, .byte, .xword, nword, and .asciiz pseudo-ops, along with .align, .skip, .global, and .local, to define data in .data, .rodata, and .bss sections.

! --------.data-----------------
        ! the .data section is used for normal read/write data
        .section        ".data"

        ! iii is a global integer (word), "iii"
        .global iii
        .align  4
iii:
        .word   12345678


        ! sss is a global short (half)
        .global sss
        .align  2
sss:
        .half   12345


        ! ccc is a static (local) char (byte)
        .local  ccc
        .align  1
ccc:
        .byte   12


        ! lll is a a global long long (xword)
        .global lll
        .align  8
lll:
        .xword  1234567812345678


        ! aaa is a global char string 
        .global aaa
        .align  1
aaa:
        .asciiz "a string"


        ! sss is a global pointer to a string (absolute addressing)
        .global sss
        .align  8
sss:
        .nword  aaa


        ! --------.rodata-------------------
        ! the .rodata section is used for read-only data
        .section        ".rodata"

        ! jjj is a global read-only integer (word)
        .global jjj
        .align  4
jjj:
        .word   12345678


        ! ---------.bss---------------------
        ! the .bss section is used for data allocated (as zeroes) at run-time
        ! data in this section does not occupy space in the ELF file
        .section        ".bss"

        ! kkk is a global "bss" integer allocated at run-time 
        .global kkk
        .align  4
kkk:
        .skip   4