c-cris.texi 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. @c Copyright (C) 2002-2015 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 CRIS description contributed by Axis Communications.
  5. @ifset GENERIC
  6. @page
  7. @node CRIS-Dependent
  8. @chapter CRIS Dependent Features
  9. @end ifset
  10. @ifclear GENERIC
  11. @node Machine Dependencies
  12. @chapter CRIS Dependent Features
  13. @end ifclear
  14. @cindex CRIS support
  15. @menu
  16. * CRIS-Opts:: Command-line Options
  17. * CRIS-Expand:: Instruction expansion
  18. * CRIS-Symbols:: Symbols
  19. * CRIS-Syntax:: Syntax
  20. @end menu
  21. @node CRIS-Opts
  22. @section Command-line Options
  23. @cindex options, CRIS
  24. @cindex CRIS options
  25. The CRIS version of @code{@value{AS}} has these
  26. machine-dependent command-line options.
  27. @cindex @option{--emulation=criself} command line option, CRIS
  28. @cindex @option{--emulation=crisaout} command line option, CRIS
  29. @cindex CRIS @option{--emulation=criself} command line option
  30. @cindex CRIS @option{--emulation=crisaout} command line option
  31. The format of the generated object files can be either ELF or
  32. a.out, specified by the command-line options
  33. @option{--emulation=crisaout} and @option{--emulation=criself}.
  34. The default is ELF (criself), unless @code{@value{AS}} has been
  35. configured specifically for a.out by using the configuration
  36. name @code{cris-axis-aout}.
  37. @cindex @option{--underscore} command line option, CRIS
  38. @cindex @option{--no-underscore} command line option, CRIS
  39. @cindex CRIS @option{--underscore} command line option
  40. @cindex CRIS @option{--no-underscore} command line option
  41. There are two different link-incompatible ELF object file
  42. variants for CRIS, for use in environments where symbols are
  43. expected to be prefixed by a leading @samp{_} character and for
  44. environments without such a symbol prefix. The variant used for
  45. GNU/Linux port has no symbol prefix. Which variant to produce
  46. is specified by either of the options @option{--underscore} and
  47. @option{--no-underscore}. The default is @option{--underscore}.
  48. Since symbols in CRIS a.out objects are expected to have a
  49. @samp{_} prefix, specifying @option{--no-underscore} when
  50. generating a.out objects is an error. Besides the object format
  51. difference, the effect of this option is to parse register names
  52. differently (@pxref{crisnous}). The @option{--no-underscore}
  53. option makes a @samp{$} register prefix mandatory.
  54. @cindex @option{--pic} command line option, CRIS
  55. @cindex CRIS @option{--pic} command line option
  56. @cindex Position-independent code, CRIS
  57. @cindex CRIS position-independent code
  58. The option @option{--pic} must be passed to @code{@value{AS}} in
  59. order to recognize the symbol syntax used for ELF (SVR4 PIC)
  60. position-independent-code (@pxref{crispic}). This will also
  61. affect expansion of instructions. The expansion with
  62. @option{--pic} will use PC-relative rather than (slightly
  63. faster) absolute addresses in those expansions. This option is only
  64. valid when generating ELF format object files.
  65. @cindex @option{--march=@var{architecture}} command line option, CRIS
  66. @cindex CRIS @option{--march=@var{architecture}} command line option
  67. @cindex Architecture variant option, CRIS
  68. @cindex CRIS architecture variant option
  69. The option @option{--march=@var{architecture}}
  70. @anchor{march-option}specifies the recognized instruction set
  71. and recognized register names. It also controls the
  72. architecture type of the object file. Valid values for
  73. @var{architecture} are:
  74. @table @code
  75. @item v0_v10
  76. All instructions and register names for any architecture variant
  77. in the set v0@dots{}v10 are recognized. This is the
  78. default if the target is configured as cris-*.
  79. @item v10
  80. Only instructions and register names for CRIS v10 (as found in
  81. ETRAX 100 LX) are recognized. This is the default if the target
  82. is configured as crisv10-*.
  83. @item v32
  84. Only instructions and register names for CRIS v32 (code name
  85. Guinness) are recognized. This is the default if the target is
  86. configured as crisv32-*. This value implies
  87. @option{--no-mul-bug-abort}. (A subsequent
  88. @option{--mul-bug-abort} will turn it back on.)
  89. @item common_v10_v32
  90. Only instructions with register names and addressing modes with
  91. opcodes common to the v10 and v32 are recognized.
  92. @end table
  93. @cindex @option{-N} command line option, CRIS
  94. @cindex CRIS @option{-N} command line option
  95. When @option{-N} is specified, @code{@value{AS}} will emit a
  96. warning when a 16-bit branch instruction is expanded into a
  97. 32-bit multiple-instruction construct (@pxref{CRIS-Expand}).
  98. @cindex @option{--no-mul-bug-abort} command line option, CRIS
  99. @cindex @option{--mul-bug-abort} command line option, CRIS
  100. @cindex CRIS @option{--no-mul-bug-abort} command line option
  101. @cindex CRIS @option{--mul-bug-abort} command line option
  102. Some versions of the CRIS v10, for example in the Etrax 100 LX,
  103. contain a bug that causes destabilizing memory accesses when a
  104. multiply instruction is executed with certain values in the
  105. first operand just before a cache-miss. When the
  106. @option{--mul-bug-abort} command line option is active (the
  107. default value), @code{@value{AS}} will refuse to assemble a file
  108. containing a multiply instruction at a dangerous offset, one
  109. that could be the last on a cache-line, or is in a section with
  110. insufficient alignment. This placement checking does not catch
  111. any case where the multiply instruction is dangerously placed
  112. because it is located in a delay-slot. The
  113. @option{--mul-bug-abort} command line option turns off the
  114. checking.
  115. @node CRIS-Expand
  116. @section Instruction expansion
  117. @cindex instruction expansion, CRIS
  118. @cindex CRIS instruction expansion
  119. @code{@value{AS}} will silently choose an instruction that fits
  120. the operand size for @samp{[register+constant]} operands. For
  121. example, the offset @code{127} in @code{move.d [r3+127],r4} fits
  122. in an instruction using a signed-byte offset. Similarly,
  123. @code{move.d [r2+32767],r1} will generate an instruction using a
  124. 16-bit offset. For symbolic expressions and constants that do
  125. not fit in 16 bits including the sign bit, a 32-bit offset is
  126. generated.
  127. For branches, @code{@value{AS}} will expand from a 16-bit branch
  128. instruction into a sequence of instructions that can reach a
  129. full 32-bit address. Since this does not correspond to a single
  130. instruction, such expansions can optionally be warned about.
  131. @xref{CRIS-Opts}.
  132. If the operand is found to fit the range, a @code{lapc} mnemonic
  133. will translate to a @code{lapcq} instruction. Use @code{lapc.d}
  134. to force the 32-bit @code{lapc} instruction.
  135. Similarly, the @code{addo} mnemonic will translate to the
  136. shortest fitting instruction of @code{addoq}, @code{addo.w} and
  137. @code{addo.d}, when used with a operand that is a constant known
  138. at assembly time.
  139. @node CRIS-Symbols
  140. @section Symbols
  141. @cindex Symbols, built-in, CRIS
  142. @cindex Symbols, CRIS, built-in
  143. @cindex CRIS built-in symbols
  144. @cindex Built-in symbols, CRIS
  145. Some symbols are defined by the assembler. They're intended to
  146. be used in conditional assembly, for example:
  147. @smallexample
  148. .if ..asm.arch.cris.v32
  149. @var{code for CRIS v32}
  150. .elseif ..asm.arch.cris.common_v10_v32
  151. @var{code common to CRIS v32 and CRIS v10}
  152. .elseif ..asm.arch.cris.v10 | ..asm.arch.cris.any_v0_v10
  153. @var{code for v10}
  154. .else
  155. .error "Code needs to be added here."
  156. .endif
  157. @end smallexample
  158. These symbols are defined in the assembler, reflecting
  159. command-line options, either when specified or the default.
  160. They are always defined, to 0 or 1.
  161. @table @code
  162. @item ..asm.arch.cris.any_v0_v10
  163. This symbol is non-zero when @option{--march=v0_v10} is specified
  164. or the default.
  165. @item ..asm.arch.cris.common_v10_v32
  166. Set according to the option @option{--march=common_v10_v32}.
  167. @item ..asm.arch.cris.v10
  168. Reflects the option @option{--march=v10}.
  169. @item ..asm.arch.cris.v32
  170. Corresponds to @option{--march=v10}.
  171. @end table
  172. Speaking of symbols, when a symbol is used in code, it can have
  173. a suffix modifying its value for use in position-independent
  174. code. @xref{CRIS-Pic}.
  175. @node CRIS-Syntax
  176. @section Syntax
  177. There are different aspects of the CRIS assembly syntax.
  178. @menu
  179. * CRIS-Chars:: Special Characters
  180. * CRIS-Pic:: Position-Independent Code Symbols
  181. * CRIS-Regs:: Register Names
  182. * CRIS-Pseudos:: Assembler Directives
  183. @end menu
  184. @node CRIS-Chars
  185. @subsection Special Characters
  186. @cindex line comment characters, CRIS
  187. @cindex CRIS line comment characters
  188. The character @samp{#} is a line comment character. It starts a
  189. comment if and only if it is placed at the beginning of a line.
  190. A @samp{;} character starts a comment anywhere on the line,
  191. causing all characters up to the end of the line to be ignored.
  192. A @samp{@@} character is handled as a line separator equivalent
  193. to a logical new-line character (except in a comment), so
  194. separate instructions can be specified on a single line.
  195. @node CRIS-Pic
  196. @subsection Symbols in position-independent code
  197. @cindex Symbols in position-independent code, CRIS
  198. @cindex CRIS symbols in position-independent code
  199. @cindex Position-independent code, symbols in, CRIS
  200. When generating @anchor{crispic}position-independent code (SVR4
  201. PIC) for use in cris-axis-linux-gnu or crisv32-axis-linux-gnu
  202. shared libraries, symbol
  203. suffixes are used to specify what kind of run-time symbol lookup
  204. will be used, expressed in the object as different
  205. @emph{relocation types}. Usually, all absolute symbol values
  206. must be located in a table, the @emph{global offset table},
  207. leaving the code position-independent; independent of values of
  208. global symbols and independent of the address of the code. The
  209. suffix modifies the value of the symbol, into for example an
  210. index into the global offset table where the real symbol value
  211. is entered, or a PC-relative value, or a value relative to the
  212. start of the global offset table. All symbol suffixes start
  213. with the character @samp{:} (omitted in the list below). Every
  214. symbol use in code or a read-only section must therefore have a
  215. PIC suffix to enable a useful shared library to be created.
  216. Usually, these constructs must not be used with an additive
  217. constant offset as is usually allowed, i.e.@: no 4 as in
  218. @code{symbol + 4} is allowed. This restriction is checked at
  219. link-time, not at assembly-time.
  220. @table @code
  221. @item GOT
  222. Attaching this suffix to a symbol in an instruction causes the
  223. symbol to be entered into the global offset table. The value is
  224. a 32-bit index for that symbol into the global offset table.
  225. The name of the corresponding relocation is
  226. @samp{R_CRIS_32_GOT}. Example: @code{move.d
  227. [$r0+extsym:GOT],$r9}
  228. @item GOT16
  229. Same as for @samp{GOT}, but the value is a 16-bit index into the
  230. global offset table. The corresponding relocation is
  231. @samp{R_CRIS_16_GOT}. Example: @code{move.d
  232. [$r0+asymbol:GOT16],$r10}
  233. @item PLT
  234. This suffix is used for function symbols. It causes a
  235. @emph{procedure linkage table}, an array of code stubs, to be
  236. created at the time the shared object is created or linked
  237. against, together with a global offset table entry. The value
  238. is a pc-relative offset to the corresponding stub code in the
  239. procedure linkage table. This arrangement causes the run-time
  240. symbol resolver to be called to look up and set the value of the
  241. symbol the first time the function is called (at latest;
  242. depending environment variables). It is only safe to leave the
  243. symbol unresolved this way if all references are function calls.
  244. The name of the relocation is @samp{R_CRIS_32_PLT_PCREL}.
  245. Example: @code{add.d fnname:PLT,$pc}
  246. @item PLTG
  247. Like PLT, but the value is relative to the beginning of the
  248. global offset table. The relocation is
  249. @samp{R_CRIS_32_PLT_GOTREL}. Example: @code{move.d
  250. fnname:PLTG,$r3}
  251. @item GOTPLT
  252. Similar to @samp{PLT}, but the value of the symbol is a 32-bit
  253. index into the global offset table. This is somewhat of a mix
  254. between the effect of the @samp{GOT} and the @samp{PLT} suffix;
  255. the difference to @samp{GOT} is that there will be a procedure
  256. linkage table entry created, and that the symbol is assumed to
  257. be a function entry and will be resolved by the run-time
  258. resolver as with @samp{PLT}. The relocation is
  259. @samp{R_CRIS_32_GOTPLT}. Example: @code{jsr
  260. [$r0+fnname:GOTPLT]}
  261. @item GOTPLT16
  262. A variant of @samp{GOTPLT} giving a 16-bit value. Its
  263. relocation name is @samp{R_CRIS_16_GOTPLT}. Example: @code{jsr
  264. [$r0+fnname:GOTPLT16]}
  265. @item GOTOFF
  266. This suffix must only be attached to a local symbol, but may be
  267. used in an expression adding an offset. The value is the
  268. address of the symbol relative to the start of the global offset
  269. table. The relocation name is @samp{R_CRIS_32_GOTREL}.
  270. Example: @code{move.d [$r0+localsym:GOTOFF],r3}
  271. @end table
  272. @node CRIS-Regs
  273. @subsection Register names
  274. @cindex register names, CRIS
  275. @cindex CRIS register names
  276. A @samp{$} character may always prefix a general or special
  277. register name in an instruction operand but is mandatory when
  278. the option @option{--no-underscore} is specified or when the
  279. @code{.syntax register_prefix} directive is in effect
  280. (@pxref{crisnous}). Register names are case-insensitive.
  281. @node CRIS-Pseudos
  282. @subsection Assembler Directives
  283. @cindex assembler directives, CRIS
  284. @cindex pseudo-ops, CRIS
  285. @cindex CRIS assembler directives
  286. @cindex CRIS pseudo-ops
  287. There are a few CRIS-specific pseudo-directives in addition to
  288. the generic ones. @xref{Pseudo Ops}. Constants emitted by
  289. pseudo-directives are in little-endian order for CRIS. There is
  290. no support for floating-point-specific directives for CRIS.
  291. @table @code
  292. @item .dword EXPRESSIONS
  293. @cindex assembler directive .dword, CRIS
  294. @cindex pseudo-op .dword, CRIS
  295. @cindex CRIS assembler directive .dword
  296. @cindex CRIS pseudo-op .dword
  297. The @code{.dword} directive is a synonym for @code{.int},
  298. expecting zero or more EXPRESSIONS, separated by commas. For
  299. each expression, a 32-bit little-endian constant is emitted.
  300. @item .syntax ARGUMENT
  301. @cindex assembler directive .syntax, CRIS
  302. @cindex pseudo-op .syntax, CRIS
  303. @cindex CRIS assembler directive .syntax
  304. @cindex CRIS pseudo-op .syntax
  305. The @code{.syntax} directive takes as @var{ARGUMENT} one of the
  306. following case-sensitive choices.
  307. @table @code
  308. @item no_register_prefix
  309. The @code{.syntax no_register_prefix} @anchor{crisnous}directive
  310. makes a @samp{$} character prefix on all registers optional. It
  311. overrides a previous setting, including the corresponding effect
  312. of the option @option{--no-underscore}. If this directive is
  313. used when ordinary symbols do not have a @samp{_} character
  314. prefix, care must be taken to avoid ambiguities whether an
  315. operand is a register or a symbol; using symbols with names the
  316. same as general or special registers then invoke undefined
  317. behavior.
  318. @item register_prefix
  319. This directive makes a @samp{$} character prefix on all
  320. registers mandatory. It overrides a previous setting, including
  321. the corresponding effect of the option @option{--underscore}.
  322. @item leading_underscore
  323. This is an assertion directive, emitting an error if the
  324. @option{--no-underscore} option is in effect.
  325. @item no_leading_underscore
  326. This is the opposite of the @code{.syntax leading_underscore}
  327. directive and emits an error if the option @option{--underscore}
  328. is in effect.
  329. @end table
  330. @item .arch ARGUMENT
  331. @cindex assembler directive .arch, CRIS
  332. @cindex pseudo-op .arch, CRIS
  333. @cindex CRIS assembler directive .arch
  334. @cindex CRIS pseudo-op .arch
  335. This is an assertion directive, giving an error if the specified
  336. @var{ARGUMENT} is not the same as the specified or default value
  337. for the @option{--march=@var{architecture}} option
  338. (@pxref{march-option}).
  339. @c If you compare with md_pseudo_table, you see that we don't
  340. @c document ".file" and ".loc" here. This is because we're just
  341. @c wrapping the corresponding ELF function and emitting an error for
  342. @c a.out.
  343. @end table