SPARC Assembly Language Reference Manual

Exit Print View

Updated: July 2014
 
 

5.2.1 32–Bit Absolute

An example of 32–bit absolute assembly code for the function add() shown earlier looks like this:

add:
         sethi   %hi(sum),%o4
         ld      [%o4+%lo(sum)],%o5
         add     %o5,%o0,%o3
         retl
         st      %o3,[%o4+%lo(sum)]

It takes two instructions to form the address of sum. The %hi() operator tells the assembler to create a R_SPARC_HI22 relocation symbol sum, and the %lo(sum) operator creates a R_SPARC_LO10 relocation on the symbol sum.