c-arc.texi 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. @c Copyright (C) 2000-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. @ifset GENERIC
  5. @page
  6. @node ARC-Dependent
  7. @chapter ARC Dependent Features
  8. @end ifset
  9. @ifclear GENERIC
  10. @node Machine Dependencies
  11. @chapter ARC Dependent Features
  12. @end ifclear
  13. @set ARC_CORE_DEFAULT 6
  14. @cindex ARC support
  15. @menu
  16. * ARC Options:: Options
  17. * ARC Syntax:: Syntax
  18. * ARC Directives:: ARC Machine Directives
  19. * ARC Modifiers:: ARC Assembler Modifiers
  20. * ARC Symbols:: ARC Pre-defined Symbols
  21. * ARC Opcodes:: Opcodes
  22. @end menu
  23. @node ARC Options
  24. @section Options
  25. @cindex ARC options
  26. @cindex options for ARC
  27. The following options control the type of CPU for which code is
  28. assembled, and generic constraints on the code generated:
  29. @table @code
  30. @item -mcpu=@var{cpu}
  31. @cindex @code{-mcpu=@var{cpu}} command line option, ARC
  32. Set architecture type and register usage for @var{cpu}. There are
  33. also shortcut alias options available for backward compatibility and
  34. convenience. Supported values for @var{cpu} are
  35. @table @code
  36. @cindex @code{mA6} command line option, ARC
  37. @cindex @code{marc600} command line option, ARC
  38. @item arc600
  39. Assemble for ARC 600. Aliases: @code{-mA6}, @code{-mARC600}.
  40. @item arc601
  41. @cindex @code{mARC601} command line option, ARC
  42. Assemble for ARC 601. Alias: @code{-mARC601}.
  43. @item arc700
  44. @cindex @code{mA7} command line option, ARC
  45. @cindex @code{mARC700} command line option, ARC
  46. Assemble for ARC 700. Aliases: @code{-mA7}, @code{-mARC700}.
  47. @item arcem
  48. @cindex @code{mEM} command line option, ARC
  49. Assemble for ARC EM. Aliases: @code{-mEM}
  50. @item archs
  51. @cindex @code{mHS} command line option, ARC
  52. Assemble for ARC HS. Aliases: @code{-mHS}, @code{-mav2hs}.
  53. @end table
  54. Note: the @code{.cpu} directive can to be used to select a core
  55. variant from within assembly code.
  56. @cindex @code{-EB} command line option, ARC
  57. @item -EB
  58. This option specifies that the output generated by the assembler should
  59. be marked as being encoded for a big-endian processor.
  60. @cindex @code{-EL} command line option, ARC
  61. @item -EL
  62. This option specifies that the output generated by the assembler should
  63. be marked as being encoded for a little-endian processor - this is the
  64. default.
  65. @cindex @code{-mcode-density} command line option, ARC
  66. @item -mcode-density
  67. This option turns on Code Density instructions. Only valid for ARC EM
  68. processors.
  69. @end table
  70. @node ARC Syntax
  71. @section Syntax
  72. @menu
  73. * ARC-Chars:: Special Characters
  74. * ARC-Regs:: Register Names
  75. @end menu
  76. @node ARC-Chars
  77. @subsection Special Characters
  78. @table @code
  79. @item %
  80. @cindex register name prefix character, ARC
  81. @cindex ARC register name prefix character
  82. A register name can optionally be prefixed by a @samp{%} character. So
  83. register @code{%r0} is equivalent to @code{r0} in the assembly code.
  84. @item #
  85. @cindex line comment character, ARC
  86. @cindex ARC line comment character
  87. The presence of a @samp{#} character within a line (but not at the
  88. start of a line) indicates the start of a comment that extends to the
  89. end of the current line.
  90. @emph{Note:} if a line starts with a @samp{#} character then it can
  91. also be a logical line number directive (@pxref{Comments}) or a
  92. preprocessor control command (@pxref{Preprocessing}).
  93. @item @@
  94. @cindex symbol prefix character, ARC
  95. @cindex ARC symbol prefix character
  96. Prefixing an operand with an @samp{@@} specifies that the operand is a
  97. symbol and not a register. This is how the assembler disambiguates
  98. the use of an ARC register name as a symbol. So the instruction
  99. @example
  100. mov r0, @@r0
  101. @end example
  102. moves the address of symbol @code{r0} into register @code{r0}.
  103. @item `
  104. @cindex line separator, ARC
  105. @cindex statement separator, ARC
  106. @cindex ARC line separator
  107. The @samp{`} (backtick) character is used to separate statements on a
  108. single line.
  109. @cindex line
  110. @item -
  111. @cindex C preprocessor macro separator, ARC
  112. @cindex ARC C preprocessor macro separator
  113. Used as a separator to obtain a sequence of commands from a C
  114. preprocessor macro.
  115. @end table
  116. @node ARC-Regs
  117. @subsection Register Names
  118. @cindex ARC register names
  119. @cindex register names, ARC
  120. The ARC assembler uses the following register names for its core
  121. registers:
  122. @table @code
  123. @item r0-r31
  124. @cindex core general registers, ARC
  125. @cindex ARC core general registers
  126. The core general registers. Registers @code{r26} through @code{r31}
  127. have special functions, and are usually referred to by those synonyms.
  128. @item gp
  129. @cindex global pointer, ARC
  130. @cindex ARC global pointer
  131. The global pointer and a synonym for @code{r26}.
  132. @item fp
  133. @cindex frame pointer, ARC
  134. @cindex ARC frame pointer
  135. The frame pointer and a synonym for @code{r27}.
  136. @item sp
  137. @cindex stack pointer, ARC
  138. @cindex ARC stack pointer
  139. The stack pointer and a synonym for @code{r28}.
  140. @item ilink1
  141. @cindex level 1 interrupt link register, ARC
  142. @cindex ARC level 1 interrupt link register
  143. For ARC 600 and ARC 700, the level 1 interrupt link register and a
  144. synonym for @code{r29}. Not supported for ARCv2.
  145. @item ilink
  146. @cindex interrupt link register, ARC
  147. @cindex ARC interrupt link register
  148. For ARCv2, the interrupt link register and a synonym for @code{r29}.
  149. Not supported for ARC 600 and ARC 700.
  150. @item ilink2
  151. @cindex level 2 interrupt link register, ARC
  152. @cindex ARC level 2 interrupt link register
  153. For ARC 600 and ARC 700, the level 2 interrupt link register and a
  154. synonym for @code{r30}. Not supported for ARC v2.
  155. @item blink
  156. @cindex link register, ARC
  157. @cindex ARC link register
  158. The link register and a synonym for @code{r31}.
  159. @item r32-r59
  160. @cindex extension core registers, ARC
  161. @cindex ARC extension core registers
  162. The extension core registers.
  163. @item lp_count
  164. @cindex loop counter, ARC
  165. @cindex ARC loop counter
  166. The loop count register.
  167. @item pcl
  168. @cindex word aligned program counter, ARC
  169. @cindex ARC word aligned program counter
  170. The word aligned program counter.
  171. @end table
  172. In addition the ARC processor has a large number of @emph{auxiliary
  173. registers}. The precise set depends on the extensions being
  174. supported, but the following baseline set are always defined:
  175. @table @code
  176. @item identity
  177. @cindex Processor Identification register, ARC
  178. @cindex ARC Processor Identification register
  179. Processor Identification register. Auxiliary register address 0x4.
  180. @item pc
  181. @cindex Program Counter, ARC
  182. @cindex ARC Program Counter
  183. Program Counter. Auxiliary register address 0x6.
  184. @item status32
  185. @cindex Status register, ARC
  186. @cindex ARC Status register
  187. Status register. Auxiliary register address 0x0a.
  188. @item bta
  189. @cindex Branch Target Address, ARC
  190. @cindex ARC Branch Target Address
  191. Branch Target Address. Auxiliary register address 0x412.
  192. @item ecr
  193. @cindex Exception Cause Register, ARC
  194. @cindex ARC Exception Cause Register
  195. Exception Cause Register. Auxiliary register address 0x403.
  196. @item int_vector_base
  197. @cindex Interrupt Vector Base address, ARC
  198. @cindex ARC Interrupt Vector Base address
  199. Interrupt Vector Base address. Auxiliary register address 0x25.
  200. @item status32_p0
  201. @cindex Stored STATUS32 register on entry to level P0 interrupts, ARC
  202. @cindex ARC Stored STATUS32 register on entry to level P0 interrupts
  203. Stored STATUS32 register on entry to level P0 interrupts. Auxiliary
  204. register address 0xb.
  205. @item aux_user_sp
  206. @cindex Saved User Stack Pointer, ARC
  207. @cindex ARC Saved User Stack Pointer
  208. Saved User Stack Pointer. Auxiliary register address 0xd.
  209. @item eret
  210. @cindex Exception Return Address, ARC
  211. @cindex ARC Exception Return Address
  212. Exception Return Address. Auxiliary register address 0x400.
  213. @item erbta
  214. @cindex BTA saved on exception entry, ARC
  215. @cindex ARC BTA saved on exception entry
  216. BTA saved on exception entry. Auxiliary register address 0x401.
  217. @item erstatus
  218. @cindex STATUS32 saved on exception, ARC
  219. @cindex ARC STATUS32 saved on exception
  220. STATUS32 saved on exception. Auxiliary register address 0x402.
  221. @item bcr_ver
  222. @cindex Build Configuration Registers Version, ARC
  223. @cindex ARC Build Configuration Registers Version
  224. Build Configuration Registers Version. Auxiliary register address 0x60.
  225. @item bta_link_build
  226. @cindex Build configuration for: BTA Registers, ARC
  227. @cindex ARC Build configuration for: BTA Registers
  228. Build configuration for: BTA Registers. Auxiliary register address 0x63.
  229. @item vecbase_ac_build
  230. @cindex Build configuration for: Interrupts, ARC
  231. @cindex ARC Build configuration for: Interrupts
  232. Build configuration for: Interrupts. Auxiliary register address 0x68.
  233. @item rf_build
  234. @cindex Build configuration for: Core Registers, ARC
  235. @cindex ARC Build configuration for: Core Registers
  236. Build configuration for: Core Registers. Auxiliary register address 0x6e.
  237. @item dccm_build
  238. @cindex DCCM RAM Configuration Register, ARC
  239. @cindex ARC DCCM RAM Configuration Register
  240. DCCM RAM Configuration Register. Auxiliary register address 0xc1.
  241. @end table
  242. Additional auxiliary register names are defined according to the
  243. processor architecture version and extensions selected by the options.
  244. @node ARC Directives
  245. @section ARC Machine Directives
  246. @cindex machine directives, ARC
  247. @cindex ARC machine directives
  248. The ARC version of @code{@value{AS}} supports the following additional
  249. machine directives:
  250. @table @code
  251. @cindex @code{lcomm} directive
  252. @item .lcomm @var{symbol} , @var{length}[, @var{alignment}]
  253. Reserve @var{length} (an absolute expression) bytes for a local common
  254. denoted by @var{symbol}. The section and value of @var{symbol} are
  255. those of the new local common. The addresses are allocated in the bss
  256. section, so that at run-time the bytes start off zeroed. Since
  257. @var{symbol} is not declared global, it is normally not visible to
  258. @code{@value{LD}}. The optional third parameter, @var{alignment},
  259. specifies the desired alignment of the symbol in the bss section,
  260. specified as a byte boundary (for example, an alignment of 16 means
  261. that the least significant 4 bits of the address should be zero). The
  262. alignment must be an absolute expression, and it must be a power of
  263. two. If no alignment is specified, as will set the alignment to the
  264. largest power of two less than or equal to the size of the symbol, up
  265. to a maximum of 16.
  266. @cindex @code{lcommon} directive
  267. @item .lcommon @var{symbol} , @var{length}[, @var{alignment}]
  268. The same as @code{lcomm} directive.
  269. @cindex @code{cpu} directive, ARC
  270. @cindex @code{cpu} directive, ARC
  271. The @code{.cpu} directive must be followed by the desired core
  272. version. Permitted values for CPU are:
  273. @table @code
  274. @item ARC600
  275. Assemble for the ARC600 instruction set.
  276. @item ARC700
  277. Assemble for the ARC700 instruction set.
  278. @item EM
  279. Assemble for the ARC EM instruction set.
  280. @item HS
  281. Assemble for the ARC HS instruction set.
  282. @end table
  283. Note: the @code{.cpu} directive overrides the command line option
  284. @code{-mcpu=@var{cpu}}; a warning is emitted when the version is not
  285. consistent between the two.
  286. @end table
  287. @node ARC Modifiers
  288. @section ARC Assembler Modifiers
  289. The following additional assembler modifiers have been added for
  290. position-independent code. These modifiers are available only with
  291. the ARC 700 and above processors and generate relocation entries,
  292. which are interpreted by the linker as follows:
  293. @table @code
  294. @item @@pcl(@var{symbol})
  295. @cindex @@pcl(@var{symbol}), ARC modifier
  296. Relative distance of @var{symbol}'s from the current program counter
  297. location.
  298. @item @@gotpc(@var{symbol})
  299. @cindex @@gotpc(@var{symbol}), ARC modifier
  300. Relative distance of @var{symbol}'s Global Offset Table entry from the
  301. current program counter location.
  302. @item @@gotoff(@var{symbol})
  303. @cindex @@gotoff(@var{symbol}), ARC modifier
  304. Distance of @var{symbol} from the base of the Global Offset Table.
  305. @item @@plt(@var{symbol})
  306. @cindex @@plt(@var{symbol}), ARC modifier
  307. Distance of @var{symbol}'s Procedure Linkage Table entry from the
  308. current program counter. This is valid only with branch and link
  309. instructions and PC-relative calls.
  310. @item @@sda(@var{symbol})
  311. @cindex @@sda(@var{symbol}), ARC modifier
  312. Relative distance of @var{symbol} from the base of the Small Data
  313. Pointer.
  314. @end table
  315. @node ARC Symbols
  316. @section ARC Pre-defined Symbols
  317. The following assembler symbols will prove useful when developing
  318. position-independent code. These symbols are available only with the
  319. ARC 700 and above processors.
  320. @table @code
  321. @item __GLOBAL_OFFSET_TABLE__
  322. @cindex __GLOBAL_OFFSET_TABLE__, ARC pre-defined symbol
  323. Symbol referring to the base of the Global Offset Table.
  324. @item __DYNAMIC__
  325. @cindex __DYNAMIC__, ARC pre-defined symbol
  326. An alias for the Global Offset Table
  327. @code{Base__GLOBAL_OFFSET_TABLE__}. It can be used only with
  328. @code{@@gotpc} modifiers.
  329. @end table
  330. @node ARC Opcodes
  331. @section Opcodes
  332. @cindex ARC opcodes
  333. @cindex opcodes for ARC
  334. For information on the ARC instruction set, see @cite{ARC Programmers
  335. Reference Manual}, available where you download the processor IP library.