1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<!-- This file documents the GNU Assembler "as". 4 5Copyright (C) 1991-2021 Free Software Foundation, Inc. 6 7Permission is granted to copy, distribute and/or modify this document 8under the terms of the GNU Free Documentation License, Version 1.3 9or any later version published by the Free Software Foundation; 10with no Invariant Sections, with no Front-Cover Texts, and with no 11Back-Cover Texts. A copy of the license is included in the 12section entitled "GNU Free Documentation License". 13 --> 14<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 15<head> 16<title>Using as: Nios II Relocations</title> 17 18<meta name="description" content="Using as: Nios II Relocations"> 19<meta name="keywords" content="Using as: Nios II Relocations"> 20<meta name="resource-type" content="document"> 21<meta name="distribution" content="global"> 22<meta name="Generator" content="makeinfo"> 23<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 24<link href="index.html#Top" rel="start" title="Top"> 25<link href="AS-Index.html#AS-Index" rel="index" title="AS Index"> 26<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 27<link href="NiosII_002dDependent.html#NiosII_002dDependent" rel="up" title="NiosII-Dependent"> 28<link href="Nios-II-Directives.html#Nios-II-Directives" rel="next" title="Nios II Directives"> 29<link href="Nios-II-Chars.html#Nios-II-Chars" rel="previous" title="Nios II Chars"> 30<style type="text/css"> 31<!-- 32a.summary-letter {text-decoration: none} 33blockquote.smallquotation {font-size: smaller} 34div.display {margin-left: 3.2em} 35div.example {margin-left: 3.2em} 36div.indentedblock {margin-left: 3.2em} 37div.lisp {margin-left: 3.2em} 38div.smalldisplay {margin-left: 3.2em} 39div.smallexample {margin-left: 3.2em} 40div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 41div.smalllisp {margin-left: 3.2em} 42kbd {font-style:oblique} 43pre.display {font-family: inherit} 44pre.format {font-family: inherit} 45pre.menu-comment {font-family: serif} 46pre.menu-preformatted {font-family: serif} 47pre.smalldisplay {font-family: inherit; font-size: smaller} 48pre.smallexample {font-size: smaller} 49pre.smallformat {font-family: inherit; font-size: smaller} 50pre.smalllisp {font-size: smaller} 51span.nocodebreak {white-space:nowrap} 52span.nolinebreak {white-space:nowrap} 53span.roman {font-family:serif; font-weight:normal} 54span.sansserif {font-family:sans-serif; font-weight:normal} 55ul.no-bullet {list-style: none} 56--> 57</style> 58 59 60</head> 61 62<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 63<a name="Nios-II-Relocations"></a> 64<div class="header"> 65<p> 66Next: <a href="Nios-II-Directives.html#Nios-II-Directives" accesskey="n" rel="next">Nios II Directives</a>, Previous: <a href="Nios-II-Syntax.html#Nios-II-Syntax" accesskey="p" rel="previous">Nios II Syntax</a>, Up: <a href="NiosII_002dDependent.html#NiosII_002dDependent" accesskey="u" rel="up">NiosII-Dependent</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p> 67</div> 68<hr> 69<a name="Nios-II-Machine-Relocations"></a> 70<h4 class="subsection">9.31.3 Nios II Machine Relocations</h4> 71 72<a name="index-machine-relocations_002c-Nios-II"></a> 73<a name="index-Nios-II-machine-relocations"></a> 74 75<dl compact="compact"> 76<dd><a name="index-hiadj-directive_002c-Nios-II"></a> 77</dd> 78<dt><code>%hiadj(<var>expression</var>)</code></dt> 79<dd><p>Extract the upper 16 bits of <var>expression</var> and add 80one if the 15th bit is set. 81</p> 82<p>The value of <code>%hiadj(<var>expression</var>)</code> is: 83</p><div class="smallexample"> 84<pre class="smallexample">((<var>expression</var> >> 16) & 0xffff) + ((<var>expression</var> >> 15) & 0x01) 85</pre></div> 86 87<p>The <code>%hiadj</code> relocation is intended to be used with 88the <code>addi</code>, <code>ld</code> or <code>st</code> instructions 89along with a <code>%lo</code>, in order to load a 32-bit constant. 90</p> 91<div class="smallexample"> 92<pre class="smallexample">movhi r2, %hiadj(symbol) 93addi r2, r2, %lo(symbol) 94</pre></div> 95 96<a name="index-hi-directive_002c-Nios-II"></a> 97</dd> 98<dt><code>%hi(<var>expression</var>)</code></dt> 99<dd><p>Extract the upper 16 bits of <var>expression</var>. 100</p> 101<a name="index-lo-directive_002c-Nios-II"></a> 102</dd> 103<dt><code>%lo(<var>expression</var>)</code></dt> 104<dd><p>Extract the lower 16 bits of <var>expression</var>. 105</p> 106<a name="index-gprel-directive_002c-Nios-II"></a> 107</dd> 108<dt><code>%gprel(<var>expression</var>)</code></dt> 109<dd><p>Subtract the value of the symbol <code>_gp</code> from 110<var>expression</var>. 111</p> 112<p>The intention of the <code>%gprel</code> relocation is 113to have a fast small area of memory which only 114takes a 16-bit immediate to access. 115</p> 116<div class="smallexample"> 117<pre class="smallexample"> .section .sdata 118fastint: 119 .int 123 120 .section .text 121 ldw r4, %gprel(fastint)(gp) 122</pre></div> 123 124<a name="index-call-directive_002c-Nios-II"></a> 125<a name="index-call_005flo-directive_002c-Nios-II"></a> 126<a name="index-call_005fhiadj-directive_002c-Nios-II"></a> 127<a name="index-got-directive_002c-Nios-II"></a> 128<a name="index-got_005flo-directive_002c-Nios-II"></a> 129<a name="index-got_005fhiadj-directive_002c-Nios-II"></a> 130<a name="index-gotoff-directive_002c-Nios-II"></a> 131<a name="index-gotoff_005flo-directive_002c-Nios-II"></a> 132<a name="index-gotoff_005fhiadj-directive_002c-Nios-II"></a> 133<a name="index-tls_005fgd-directive_002c-Nios-II"></a> 134<a name="index-tls_005fie-directive_002c-Nios-II"></a> 135<a name="index-tls_005fle-directive_002c-Nios-II"></a> 136<a name="index-tls_005fldm-directive_002c-Nios-II"></a> 137<a name="index-tls_005fldo-directive_002c-Nios-II"></a> 138</dd> 139<dt><code>%call(<var>expression</var>)</code></dt> 140<dt><code>%call_lo(<var>expression</var>)</code></dt> 141<dt><code>%call_hiadj(<var>expression</var>)</code></dt> 142<dt><code>%got(<var>expression</var>)</code></dt> 143<dt><code>%got_lo(<var>expression</var>)</code></dt> 144<dt><code>%got_hiadj(<var>expression</var>)</code></dt> 145<dt><code>%gotoff(<var>expression</var>)</code></dt> 146<dt><code>%gotoff_lo(<var>expression</var>)</code></dt> 147<dt><code>%gotoff_hiadj(<var>expression</var>)</code></dt> 148<dt><code>%tls_gd(<var>expression</var>)</code></dt> 149<dt><code>%tls_ie(<var>expression</var>)</code></dt> 150<dt><code>%tls_le(<var>expression</var>)</code></dt> 151<dt><code>%tls_ldm(<var>expression</var>)</code></dt> 152<dt><code>%tls_ldo(<var>expression</var>)</code></dt> 153<dd> 154<p>These relocations support the ABI for Linux Systems documented in the 155<cite>Nios II Processor Reference Handbook</cite>. 156</p></dd> 157</dl> 158 159 160 161 162 163</body> 164</html> 165