1@c Copyright (C) 2012-2014 Free Software Foundation, Inc. 2@c This is part of the GAS manual. 3@c For copying conditions, see the file as.texinfo. 4@c man end 5@ifset GENERIC 6@page 7@node NiosII-Dependent 8@chapter Nios II Dependent Features 9@end ifset 10@ifclear GENERIC 11@node Machine Dependencies 12@chapter Nios II Dependent Features 13@end ifclear 14 15@cindex Altera Nios II support 16@cindex Nios support 17@cindex Nios II support 18@menu 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 24@end menu 25 26@node Nios II Options 27@section Options 28@cindex Nios II options 29@cindex options for Nios II 30 31@c man begin OPTIONS 32@table @gcctabopt 33 34@cindex @code{relax-section} command line option, Nios II 35@item -relax-section 36Replace identified out-of-range branches with PC-relative @code{jmp} 37sequences when possible. The generated code sequences are suitable 38for use in position-independent code, but there is a practical limit 39on the extended branch range because of the length of the sequences. 40This option is the default. 41 42@cindex @code{relax-all} command line option, Nios II 43@item -relax-all 44Replace branch instructions not determinable to be in range 45and all call instructions with @code{jmp} and @code{callr} sequences 46(respectively). This option generates absolute relocations against the 47target symbols and is not appropriate for position-independent code. 48 49@cindex @code{no-relax} command line option, Nios II 50@item -no-relax 51Do not replace any branches or calls. 52 53@cindex @code{EB} command line option, Nios II 54@item -EB 55Generate big-endian output. 56 57@cindex @code{EL} command line option, Nios II 58@item -EL 59Generate little-endian output. This is the default. 60 61@end table 62@c man end 63 64@node Nios II Syntax 65@section Syntax 66@menu 67* Nios II Chars:: Special Characters 68@end menu 69 70 71@node Nios II Chars 72@subsection Special Characters 73 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. 80 81 82@node Nios II Relocations 83@section Nios II Machine Relocations 84 85@cindex machine relocations, Nios II 86@cindex Nios II machine relocations 87 88@table @code 89@cindex @code{hiadj} directive, Nios II 90@item %hiadj(@var{expression}) 91Extract the upper 16 bits of @var{expression} and add 92one if the 15th bit is set. 93 94The value of @code{%hiadj(@var{expression})} is: 95@smallexample 96((@var{expression} >> 16) & 0xffff) + ((@var{expression} >> 15) & 0x01) 97@end smallexample 98 99The @code{%hiadj} relocation is intended to be used with 100the @code{addi}, @code{ld} or @code{st} instructions 101along with a @code{%lo}, in order to load a 32-bit constant. 102 103@smallexample 104movhi r2, %hiadj(symbol) 105addi r2, r2, %lo(symbol) 106@end smallexample 107 108@cindex @code{hi} directive, Nios II 109@item %hi(@var{expression}) 110Extract the upper 16 bits of @var{expression}. 111 112@cindex @code{lo} directive, Nios II 113@item %lo(@var{expression}) 114Extract the lower 16 bits of @var{expression}. 115 116@cindex @code{gprel} directive, Nios II 117@item %gprel(@var{expression}) 118Subtract the value of the symbol @code{_gp} from 119@var{expression}. 120 121The intention of the @code{%gprel} relocation is 122to have a fast small area of memory which only 123takes a 16-bit immediate to access. 124 125@smallexample 126 .section .sdata 127fastint: 128 .int 123 129 .section .text 130 ldw r4, %gprel(fastint)(gp) 131@end smallexample 132 133@cindex @code{call} directive, Nios II 134@cindex @code{call_lo} directive, Nios II 135@cindex @code{call_hiadj} directive, Nios II 136@cindex @code{got} directive, Nios II 137@cindex @code{got_lo} directive, Nios II 138@cindex @code{got_hiadj} directive, Nios II 139@cindex @code{gotoff} directive, Nios II 140@cindex @code{gotoff_lo} directive, Nios II 141@cindex @code{gotoff_hiadj} directive, Nios II 142@cindex @code{tls_gd} directive, Nios II 143@cindex @code{tls_ie} directive, Nios II 144@cindex @code{tls_le} directive, Nios II 145@cindex @code{tls_ldm} directive, Nios II 146@cindex @code{tls_ldo} directive, Nios II 147@item %call(@var{expression}) 148@item %call_lo(@var{expression}) 149@item %call_hiadj(@var{expression}) 150@itemx %got(@var{expression}) 151@itemx %got_lo(@var{expression}) 152@itemx %got_hiadj(@var{expression}) 153@itemx %gotoff(@var{expression}) 154@itemx %gotoff_lo(@var{expression}) 155@itemx %gotoff_hiadj(@var{expression}) 156@itemx %tls_gd(@var{expression}) 157@itemx %tls_ie(@var{expression}) 158@itemx %tls_le(@var{expression}) 159@itemx %tls_ldm(@var{expression}) 160@itemx %tls_ldo(@var{expression}) 161 162These relocations support the ABI for Linux Systems documented in the 163@cite{Nios II Processor Reference Handbook}. 164@end table 165 166 167@node Nios II Directives 168@section Nios II Machine Directives 169 170@cindex machine directives, Nios II 171@cindex Nios II machine directives 172 173@table @code 174 175@cindex @code{align} directive, Nios II 176@item .align @var{expression} [, @var{expression}] 177This is the generic @code{.align} directive, however 178this aligns to a power of two. 179 180@cindex @code{half} directive, Nios II 181@item .half @var{expression} 182Create an aligned constant 2 bytes in size. 183 184@cindex @code{word} directive, Nios II 185@item .word @var{expression} 186Create an aligned constant 4 bytes in size. 187 188@cindex @code{dword} directive, Nios II 189@item .dword @var{expression} 190Create an aligned constant 8 bytes in size. 191 192@cindex @code{2byte} directive, Nios II 193@item .2byte @var{expression} 194Create an unaligned constant 2 bytes in size. 195 196@cindex @code{4byte} directive, Nios II 197@item .4byte @var{expression} 198Create an unaligned constant 4 bytes in size. 199 200@cindex @code{8byte} directive, Nios II 201@item .8byte @var{expression} 202Create an unaligned constant 8 bytes in size. 203 204@cindex @code{16byte} directive, Nios II 205@item .16byte @var{expression} 206Create an unaligned constant 16 bytes in size. 207 208@cindex @code{set noat} directive, Nios II 209@item .set noat 210Allows assembly code to use @code{at} register without 211warning. Macro or relaxation expansions 212generate warnings. 213 214@cindex @code{set at} directive, Nios II 215@item .set at 216Assembly code using @code{at} register generates 217warnings, and macro expansion and relaxation are 218enabled. 219 220@cindex @code{set nobreak} directive, Nios II 221@item .set nobreak 222Allows assembly code to use @code{ba} and @code{bt} 223registers without warning. 224 225@cindex @code{set break} directive, Nios II 226@item .set break 227Turns warnings back on for using @code{ba} and @code{bt} 228registers. 229 230@cindex @code{set norelax} directive, Nios II 231@item .set norelax 232Do not replace any branches or calls. 233 234@cindex @code{set relaxsection} directive, Nios II 235@item .set relaxsection 236Replace identified out-of-range branches with 237@code{jmp} sequences (default). 238 239@cindex @code{set relaxall} directive, Nios II 240@item .set relaxsection 241Replace all branch and call instructions with 242@code{jmp} and @code{callr} sequences. 243 244@cindex @code{set} directive, Nios II 245@item .set @dots{} 246All other @code{.set} are the normal use. 247 248@end table 249 250@node Nios II Opcodes 251@section Opcodes 252 253@cindex Nios II opcodes 254@cindex opcodes for Nios II 255@code{@value{AS}} implements all the standard Nios II opcodes documented in the 256@cite{Nios II Processor Reference Handbook}, including the assembler 257pseudo-instructions. 258