<html lang="en"> <head> <title>Nios II Relocations - Using as</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Using as"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="NiosII_002dDependent.html#NiosII_002dDependent" title="NiosII-Dependent"> <link rel="prev" href="Nios-II-Syntax.html#Nios-II-Syntax" title="Nios II Syntax"> <link rel="next" href="Nios-II-Directives.html#Nios-II-Directives" title="Nios II Directives"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- This file documents the GNU Assembler "as". Copyright (C) 1991-2015 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''. --> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Nios-II-Relocations"></a> <p> Next: <a rel="next" accesskey="n" href="Nios-II-Directives.html#Nios-II-Directives">Nios II Directives</a>, Previous: <a rel="previous" accesskey="p" href="Nios-II-Syntax.html#Nios-II-Syntax">Nios II Syntax</a>, Up: <a rel="up" accesskey="u" href="NiosII_002dDependent.html#NiosII_002dDependent">NiosII-Dependent</a> <hr> </div> <h4 class="subsection">9.31.3 Nios II Machine Relocations</h4> <p><a name="index-machine-relocations_002c-Nios-II-1676"></a><a name="index-Nios-II-machine-relocations-1677"></a> <a name="index-g_t_0040code_007bhiadj_007d-directive_002c-Nios-II-1678"></a> <dl><dt><code>%hiadj(</code><var>expression</var><code>)</code><dd>Extract the upper 16 bits of <var>expression</var> and add one if the 15th bit is set. <p>The value of <code>%hiadj(</code><var>expression</var><code>)</code> is: <pre class="smallexample"> ((<var>expression</var> >> 16) & 0xffff) + ((<var>expression</var> >> 15) & 0x01) </pre> <p>The <code>%hiadj</code> relocation is intended to be used with the <code>addi</code>, <code>ld</code> or <code>st</code> instructions along with a <code>%lo</code>, in order to load a 32-bit constant. <pre class="smallexample"> movhi r2, %hiadj(symbol) addi r2, r2, %lo(symbol) </pre> <p><a name="index-g_t_0040code_007bhi_007d-directive_002c-Nios-II-1679"></a><br><dt><code>%hi(</code><var>expression</var><code>)</code><dd>Extract the upper 16 bits of <var>expression</var>. <p><a name="index-g_t_0040code_007blo_007d-directive_002c-Nios-II-1680"></a><br><dt><code>%lo(</code><var>expression</var><code>)</code><dd>Extract the lower 16 bits of <var>expression</var>. <p><a name="index-g_t_0040code_007bgprel_007d-directive_002c-Nios-II-1681"></a><br><dt><code>%gprel(</code><var>expression</var><code>)</code><dd>Subtract the value of the symbol <code>_gp</code> from <var>expression</var>. <p>The intention of the <code>%gprel</code> relocation is to have a fast small area of memory which only takes a 16-bit immediate to access. <pre class="smallexample"> .section .sdata fastint: .int 123 .section .text ldw r4, %gprel(fastint)(gp) </pre> <p><a name="index-g_t_0040code_007bcall_007d-directive_002c-Nios-II-1682"></a><a name="index-g_t_0040code_007bcall_005flo_007d-directive_002c-Nios-II-1683"></a><a name="index-g_t_0040code_007bcall_005fhiadj_007d-directive_002c-Nios-II-1684"></a><a name="index-g_t_0040code_007bgot_007d-directive_002c-Nios-II-1685"></a><a name="index-g_t_0040code_007bgot_005flo_007d-directive_002c-Nios-II-1686"></a><a name="index-g_t_0040code_007bgot_005fhiadj_007d-directive_002c-Nios-II-1687"></a><a name="index-g_t_0040code_007bgotoff_007d-directive_002c-Nios-II-1688"></a><a name="index-g_t_0040code_007bgotoff_005flo_007d-directive_002c-Nios-II-1689"></a><a name="index-g_t_0040code_007bgotoff_005fhiadj_007d-directive_002c-Nios-II-1690"></a><a name="index-g_t_0040code_007btls_005fgd_007d-directive_002c-Nios-II-1691"></a><a name="index-g_t_0040code_007btls_005fie_007d-directive_002c-Nios-II-1692"></a><a name="index-g_t_0040code_007btls_005fle_007d-directive_002c-Nios-II-1693"></a><a name="index-g_t_0040code_007btls_005fldm_007d-directive_002c-Nios-II-1694"></a><a name="index-g_t_0040code_007btls_005fldo_007d-directive_002c-Nios-II-1695"></a><br><dt><code>%call(</code><var>expression</var><code>)</code><br><dt><code>%call_lo(</code><var>expression</var><code>)</code><br><dt><code>%call_hiadj(</code><var>expression</var><code>)</code><dt><code>%got(</code><var>expression</var><code>)</code><dt><code>%got_lo(</code><var>expression</var><code>)</code><dt><code>%got_hiadj(</code><var>expression</var><code>)</code><dt><code>%gotoff(</code><var>expression</var><code>)</code><dt><code>%gotoff_lo(</code><var>expression</var><code>)</code><dt><code>%gotoff_hiadj(</code><var>expression</var><code>)</code><dt><code>%tls_gd(</code><var>expression</var><code>)</code><dt><code>%tls_ie(</code><var>expression</var><code>)</code><dt><code>%tls_le(</code><var>expression</var><code>)</code><dt><code>%tls_ldm(</code><var>expression</var><code>)</code><dt><code>%tls_ldo(</code><var>expression</var><code>)</code><dd> These relocations support the ABI for Linux Systems documented in the <cite>Nios II Processor Reference Handbook</cite>. </dl> </body></html>