1
@c Copyright 2012, 2013 Free Software Foundation, Inc.
2
@c This is part of the GAS manual.
3
@c For copying conditions, see the file as.texinfo.
8
@chapter Nios II Dependent Features
11
@node Machine Dependencies
12
@chapter Nios II Dependent Features
15
@cindex Altera Nios II support
17
@cindex Nios II support
19
* Nios II Options:: Options
20
* Nios II Syntax:: Syntax
21
* Nios II Relocations:: Relocations
22
* Nios II Directives:: Nios II Machine Directives
23
* Nios II Opcodes:: Opcodes
28
@cindex Nios II options
29
@cindex options for Nios II
34
@cindex @code{relax-section} command line option, Nios II
36
Replace identified out-of-range branches with PC-relative @code{jmp}
37
sequences when possible. The generated code sequences are suitable
38
for use in position-independent code, but there is a practical limit
39
on the extended branch range because of the length of the sequences.
40
This option is the default.
42
@cindex @code{relax-all} command line option, Nios II
44
Replace branch instructions not determinable to be in range
45
and all call instructions with @code{jmp} and @code{callr} sequences
46
(respectively). This option generates absolute relocations against the
47
target symbols and is not appropriate for position-independent code.
49
@cindex @code{no-relax} command line option, Nios II
51
Do not replace any branches or calls.
53
@cindex @code{EB} command line option, Nios II
55
Generate big-endian output.
57
@cindex @code{EL} command line option, Nios II
59
Generate little-endian output. This is the default.
67
* Nios II Chars:: Special Characters
72
@subsection Special Characters
74
@cindex line comment character, Nios II
75
@cindex Nios II line comment character
76
@cindex line separator character, Nios II
77
@cindex Nios II line separator character
78
@samp{#} is the line comment character.
79
@samp{;} is the line separator character.
82
@node Nios II Relocations
83
@section Nios II Machine Relocations
85
@cindex machine relocations, Nios II
86
@cindex Nios II machine relocations
89
@cindex @code{hiadj} directive, Nios II
90
@item %hiadj(@var{expression})
91
Extract the upper 16 bits of @var{expression} and add
92
one if the 15th bit is set.
94
The value of @code{%hiadj(@var{expression})} is:
96
((@var{expression} >> 16) & 0xffff) + ((@var{expression} >> 15) & 0x01)
99
The @code{%hiadj} relocation is intended to be used with
100
the @code{addi}, @code{ld} or @code{st} instructions
101
along with a @code{%lo}, in order to load a 32-bit constant.
104
movhi r2, %hiadj(symbol)
105
addi r2, r2, %lo(symbol)
108
@cindex @code{hi} directive, Nios II
109
@item %hi(@var{expression})
110
Extract the upper 16 bits of @var{expression}.
112
@cindex @code{lo} directive, Nios II
113
@item %lo(@var{expression})
114
Extract the lower 16 bits of @var{expression}.
116
@cindex @code{gprel} directive, Nios II
117
@item %gprel(@var{expression})
118
Subtract the value of the symbol @code{_gp} from
121
The intention of the @code{%gprel} relocation is
122
to have a fast small area of memory which only
123
takes a 16-bit immediate to access.
130
ldw r4, %gprel(fastint)(gp)
133
@cindex @code{call} directive, Nios II
134
@cindex @code{got} directive, Nios II
135
@cindex @code{gotoff} directive, Nios II
136
@cindex @code{gotoff_lo} directive, Nios II
137
@cindex @code{gotoff_hiadj} directive, Nios II
138
@cindex @code{tls_gd} directive, Nios II
139
@cindex @code{tls_ie} directive, Nios II
140
@cindex @code{tls_le} directive, Nios II
141
@cindex @code{tls_ldm} directive, Nios II
142
@cindex @code{tls_ldo} directive, Nios II
143
@item %call(@var{expression})
144
@itemx %got(@var{expression})
145
@itemx %gotoff(@var{expression})
146
@itemx %gotoff_lo(@var{expression})
147
@itemx %gotoff_hiadj(@var{expression})
148
@itemx %tls_gd(@var{expression})
149
@itemx %tls_ie(@var{expression})
150
@itemx %tls_le(@var{expression})
151
@itemx %tls_ldm(@var{expression})
152
@itemx %tls_ldo(@var{expression})
154
These relocations support the ABI for Linux Systems documented in the
155
@cite{Nios II Processor Reference Handbook}.
159
@node Nios II Directives
160
@section Nios II Machine Directives
162
@cindex machine directives, Nios II
163
@cindex Nios II machine directives
167
@cindex @code{align} directive, Nios II
168
@item .align @var{expression} [, @var{expression}]
169
This is the generic @code{.align} directive, however
170
this aligns to a power of two.
172
@cindex @code{half} directive, Nios II
173
@item .half @var{expression}
174
Create an aligned constant 2 bytes in size.
176
@cindex @code{word} directive, Nios II
177
@item .word @var{expression}
178
Create an aligned constant 4 bytes in size.
180
@cindex @code{dword} directive, Nios II
181
@item .dword @var{expression}
182
Create an aligned constant 8 bytes in size.
184
@cindex @code{2byte} directive, Nios II
185
@item .2byte @var{expression}
186
Create an unaligned constant 2 bytes in size.
188
@cindex @code{4byte} directive, Nios II
189
@item .4byte @var{expression}
190
Create an unaligned constant 4 bytes in size.
192
@cindex @code{8byte} directive, Nios II
193
@item .8byte @var{expression}
194
Create an unaligned constant 8 bytes in size.
196
@cindex @code{16byte} directive, Nios II
197
@item .16byte @var{expression}
198
Create an unaligned constant 16 bytes in size.
200
@cindex @code{set noat} directive, Nios II
202
Allows assembly code to use @code{at} register without
203
warning. Macro or relaxation expansions
206
@cindex @code{set at} directive, Nios II
208
Assembly code using @code{at} register generates
209
warnings, and macro expansion and relaxation are
212
@cindex @code{set nobreak} directive, Nios II
214
Allows assembly code to use @code{ba} and @code{bt}
215
registers without warning.
217
@cindex @code{set break} directive, Nios II
219
Turns warnings back on for using @code{ba} and @code{bt}
222
@cindex @code{set norelax} directive, Nios II
224
Do not replace any branches or calls.
226
@cindex @code{set relaxsection} directive, Nios II
227
@item .set relaxsection
228
Replace identified out-of-range branches with
229
@code{jmp} sequences (default).
231
@cindex @code{set relaxall} directive, Nios II
232
@item .set relaxsection
233
Replace all branch and call instructions with
234
@code{jmp} and @code{callr} sequences.
236
@cindex @code{set} directive, Nios II
238
All other @code{.set} are the normal use.
242
@node Nios II Opcodes
245
@cindex Nios II opcodes
246
@cindex opcodes for Nios II
247
@code{@value{AS}} implements all the standard Nios II opcodes documented in the
248
@cite{Nios II Processor Reference Handbook}, including the assembler