c-nios2.texi 7.5 KB

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