c-v850.texi 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. @c Copyright (C) 1997-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. @node V850-Dependent
  5. @chapter v850 Dependent Features
  6. @cindex V850 support
  7. @menu
  8. * V850 Options:: Options
  9. * V850 Syntax:: Syntax
  10. * V850 Floating Point:: Floating Point
  11. * V850 Directives:: V850 Machine Directives
  12. * V850 Opcodes:: Opcodes
  13. @end menu
  14. @node V850 Options
  15. @section Options
  16. @cindex V850 options (none)
  17. @cindex options for V850 (none)
  18. @code{@value{AS}} supports the following additional command-line options
  19. for the V850 processor family:
  20. @cindex command line options, V850
  21. @cindex V850 command line options
  22. @table @code
  23. @cindex @code{-wsigned_overflow} command line option, V850
  24. @item -wsigned_overflow
  25. Causes warnings to be produced when signed immediate values overflow the
  26. space available for then within their opcodes. By default this option
  27. is disabled as it is possible to receive spurious warnings due to using
  28. exact bit patterns as immediate constants.
  29. @cindex @code{-wunsigned_overflow} command line option, V850
  30. @item -wunsigned_overflow
  31. Causes warnings to be produced when unsigned immediate values overflow
  32. the space available for then within their opcodes. By default this
  33. option is disabled as it is possible to receive spurious warnings due to
  34. using exact bit patterns as immediate constants.
  35. @cindex @code{-mv850} command line option, V850
  36. @item -mv850
  37. Specifies that the assembled code should be marked as being targeted at
  38. the V850 processor. This allows the linker to detect attempts to link
  39. such code with code assembled for other processors.
  40. @cindex @code{-mv850e} command line option, V850
  41. @item -mv850e
  42. Specifies that the assembled code should be marked as being targeted at
  43. the V850E processor. This allows the linker to detect attempts to link
  44. such code with code assembled for other processors.
  45. @cindex @code{-mv850e1} command line option, V850
  46. @item -mv850e1
  47. Specifies that the assembled code should be marked as being targeted at
  48. the V850E1 processor. This allows the linker to detect attempts to link
  49. such code with code assembled for other processors.
  50. @cindex @code{-mv850any} command line option, V850
  51. @item -mv850any
  52. Specifies that the assembled code should be marked as being targeted at
  53. the V850 processor but support instructions that are specific to the
  54. extended variants of the process. This allows the production of
  55. binaries that contain target specific code, but which are also intended
  56. to be used in a generic fashion. For example libgcc.a contains generic
  57. routines used by the code produced by GCC for all versions of the v850
  58. architecture, together with support routines only used by the V850E
  59. architecture.
  60. @cindex @code{-mv850e2} command line option, V850
  61. @item -mv850e2
  62. Specifies that the assembled code should be marked as being targeted at
  63. the V850E2 processor. This allows the linker to detect attempts to link
  64. such code with code assembled for other processors.
  65. @cindex @code{-mv850e2v3} command line option, V850
  66. @item -mv850e2v3
  67. Specifies that the assembled code should be marked as being targeted at
  68. the V850E2V3 processor. This allows the linker to detect attempts to link
  69. such code with code assembled for other processors.
  70. @cindex @code{-mv850e2v4} command line option, V850
  71. @item -mv850e2v4
  72. This is an alias for @option{-mv850e3v5}.
  73. @cindex @code{-mv850e3v5} command line option, V850
  74. @item -mv850e3v5
  75. Specifies that the assembled code should be marked as being targeted at
  76. the V850E3V5 processor. This allows the linker to detect attempts to link
  77. such code with code assembled for other processors.
  78. @cindex @code{-mrelax} command line option, V850
  79. @item -mrelax
  80. Enables relaxation. This allows the .longcall and .longjump pseudo
  81. ops to be used in the assembler source code. These ops label sections
  82. of code which are either a long function call or a long branch. The
  83. assembler will then flag these sections of code and the linker will
  84. attempt to relax them.
  85. @cindex @code{-mgcc-abi} command line option, V850
  86. @item -mgcc-abi
  87. Marks the generated object file as supporting the old GCC ABI.
  88. @cindex @code{-mrh850-abi} command line option, V850
  89. @item -mrh850-abi
  90. Marks the generated object file as supporting the RH850 ABI. This is
  91. the default.
  92. @cindex @code{-m8byte-align} command line option, V850
  93. @item -m8byte-align
  94. Marks the generated object file as supporting a maximum 64-bits of
  95. alignment for variables defined in the source code.
  96. @cindex @code{-m4byte-align} command line option, V850
  97. @item -m4byte-align
  98. Marks the generated object file as supporting a maximum 32-bits of
  99. alignment for variables defined in the source code. This is the
  100. default.
  101. @cindex @code{-msoft-float} command line option, V850
  102. @item -msoft-float
  103. Marks the generated object file as not using any floating point
  104. instructions - and hence can be linked with other V850 binaries
  105. that do or do not use floating point. This is the default for
  106. binaries for architectures earlier than the @code{e2v3}.
  107. @cindex @code{-mhard-float} command line option, V850
  108. @item -mhard-float
  109. Marks the generated object file as one that uses floating point
  110. instructions - and hence can only be linked with other V850 binaries
  111. that use the same kind of floating point instructions, or with
  112. binaries that do not use floating point at all. This is the default
  113. for binaries the @code{e2v3} and later architectures.
  114. @end table
  115. @node V850 Syntax
  116. @section Syntax
  117. @menu
  118. * V850-Chars:: Special Characters
  119. * V850-Regs:: Register Names
  120. @end menu
  121. @node V850-Chars
  122. @subsection Special Characters
  123. @cindex line comment character, V850
  124. @cindex V850 line comment character
  125. @samp{#} is the line comment character. If a @samp{#} appears as the
  126. first character of a line, the whole line is treated as a comment, but
  127. in this case the line can also be a logical line number directive
  128. (@pxref{Comments}) or a preprocessor control command
  129. (@pxref{Preprocessing}).
  130. Two dashes (@samp{--}) can also be used to start a line comment.
  131. @cindex line separator, V850
  132. @cindex statement separator, V850
  133. @cindex V850 line separator
  134. The @samp{;} character can be used to separate statements on the same
  135. line.
  136. @node V850-Regs
  137. @subsection Register Names
  138. @cindex V850 register names
  139. @cindex register names, V850
  140. @code{@value{AS}} supports the following names for registers:
  141. @table @code
  142. @cindex @code{zero} register, V850
  143. @item general register 0
  144. r0, zero
  145. @item general register 1
  146. r1
  147. @item general register 2
  148. r2, hp
  149. @cindex @code{sp} register, V850
  150. @item general register 3
  151. r3, sp
  152. @cindex @code{gp} register, V850
  153. @item general register 4
  154. r4, gp
  155. @cindex @code{tp} register, V850
  156. @item general register 5
  157. r5, tp
  158. @item general register 6
  159. r6
  160. @item general register 7
  161. r7
  162. @item general register 8
  163. r8
  164. @item general register 9
  165. r9
  166. @item general register 10
  167. r10
  168. @item general register 11
  169. r11
  170. @item general register 12
  171. r12
  172. @item general register 13
  173. r13
  174. @item general register 14
  175. r14
  176. @item general register 15
  177. r15
  178. @item general register 16
  179. r16
  180. @item general register 17
  181. r17
  182. @item general register 18
  183. r18
  184. @item general register 19
  185. r19
  186. @item general register 20
  187. r20
  188. @item general register 21
  189. r21
  190. @item general register 22
  191. r22
  192. @item general register 23
  193. r23
  194. @item general register 24
  195. r24
  196. @item general register 25
  197. r25
  198. @item general register 26
  199. r26
  200. @item general register 27
  201. r27
  202. @item general register 28
  203. r28
  204. @item general register 29
  205. r29
  206. @cindex @code{ep} register, V850
  207. @item general register 30
  208. r30, ep
  209. @cindex @code{lp} register, V850
  210. @item general register 31
  211. r31, lp
  212. @cindex @code{eipc} register, V850
  213. @item system register 0
  214. eipc
  215. @cindex @code{eipsw} register, V850
  216. @item system register 1
  217. eipsw
  218. @cindex @code{fepc} register, V850
  219. @item system register 2
  220. fepc
  221. @cindex @code{fepsw} register, V850
  222. @item system register 3
  223. fepsw
  224. @cindex @code{ecr} register, V850
  225. @item system register 4
  226. ecr
  227. @cindex @code{psw} register, V850
  228. @item system register 5
  229. psw
  230. @cindex @code{ctpc} register, V850
  231. @item system register 16
  232. ctpc
  233. @cindex @code{ctpsw} register, V850
  234. @item system register 17
  235. ctpsw
  236. @cindex @code{dbpc} register, V850
  237. @item system register 18
  238. dbpc
  239. @cindex @code{dbpsw} register, V850
  240. @item system register 19
  241. dbpsw
  242. @cindex @code{ctbp} register, V850
  243. @item system register 20
  244. ctbp
  245. @end table
  246. @node V850 Floating Point
  247. @section Floating Point
  248. @cindex floating point, V850 (@sc{ieee})
  249. @cindex V850 floating point (@sc{ieee})
  250. The V850 family uses @sc{ieee} floating-point numbers.
  251. @node V850 Directives
  252. @section V850 Machine Directives
  253. @cindex machine directives, V850
  254. @cindex V850 machine directives
  255. @table @code
  256. @cindex @code{offset} directive, V850
  257. @item .offset @var{<expression>}
  258. Moves the offset into the current section to the specified amount.
  259. @cindex @code{section} directive, V850
  260. @item .section "name", <type>
  261. This is an extension to the standard .section directive. It sets the
  262. current section to be <type> and creates an alias for this section
  263. called "name".
  264. @cindex @code{.v850} directive, V850
  265. @item .v850
  266. Specifies that the assembled code should be marked as being targeted at
  267. the V850 processor. This allows the linker to detect attempts to link
  268. such code with code assembled for other processors.
  269. @cindex @code{.v850e} directive, V850
  270. @item .v850e
  271. Specifies that the assembled code should be marked as being targeted at
  272. the V850E processor. This allows the linker to detect attempts to link
  273. such code with code assembled for other processors.
  274. @cindex @code{.v850e1} directive, V850
  275. @item .v850e1
  276. Specifies that the assembled code should be marked as being targeted at
  277. the V850E1 processor. This allows the linker to detect attempts to link
  278. such code with code assembled for other processors.
  279. @cindex @code{.v850e2} directive, V850
  280. @item .v850e2
  281. Specifies that the assembled code should be marked as being targeted at
  282. the V850E2 processor. This allows the linker to detect attempts to link
  283. such code with code assembled for other processors.
  284. @cindex @code{.v850e2v3} directive, V850
  285. @item .v850e2v3
  286. Specifies that the assembled code should be marked as being targeted at
  287. the V850E2V3 processor. This allows the linker to detect attempts to link
  288. such code with code assembled for other processors.
  289. @cindex @code{.v850e2v4} directive, V850
  290. @item .v850e2v4
  291. Specifies that the assembled code should be marked as being targeted at
  292. the V850E3V5 processor. This allows the linker to detect attempts to link
  293. such code with code assembled for other processors.
  294. @cindex @code{.v850e3v5} directive, V850
  295. @item .v850e3v5
  296. Specifies that the assembled code should be marked as being targeted at
  297. the V850E3V5 processor. This allows the linker to detect attempts to link
  298. such code with code assembled for other processors.
  299. @end table
  300. @node V850 Opcodes
  301. @section Opcodes
  302. @cindex V850 opcodes
  303. @cindex opcodes for V850
  304. @code{@value{AS}} implements all the standard V850 opcodes.
  305. @code{@value{AS}} also implements the following pseudo ops:
  306. @table @code
  307. @cindex @code{hi0} pseudo-op, V850
  308. @item hi0()
  309. Computes the higher 16 bits of the given expression and stores it into
  310. the immediate operand field of the given instruction. For example:
  311. @samp{mulhi hi0(here - there), r5, r6}
  312. computes the difference between the address of labels 'here' and
  313. 'there', takes the upper 16 bits of this difference, shifts it down 16
  314. bits and then multiplies it by the lower 16 bits in register 5, putting
  315. the result into register 6.
  316. @cindex @code{lo} pseudo-op, V850
  317. @item lo()
  318. Computes the lower 16 bits of the given expression and stores it into
  319. the immediate operand field of the given instruction. For example:
  320. @samp{addi lo(here - there), r5, r6}
  321. computes the difference between the address of labels 'here' and
  322. 'there', takes the lower 16 bits of this difference and adds it to
  323. register 5, putting the result into register 6.
  324. @cindex @code{hi} pseudo-op, V850
  325. @item hi()
  326. Computes the higher 16 bits of the given expression and then adds the
  327. value of the most significant bit of the lower 16 bits of the expression
  328. and stores the result into the immediate operand field of the given
  329. instruction. For example the following code can be used to compute the
  330. address of the label 'here' and store it into register 6:
  331. @samp{movhi hi(here), r0, r6}
  332. @samp{movea lo(here), r6, r6}
  333. The reason for this special behaviour is that movea performs a sign
  334. extension on its immediate operand. So for example if the address of
  335. 'here' was 0xFFFFFFFF then without the special behaviour of the hi()
  336. pseudo-op the movhi instruction would put 0xFFFF0000 into r6, then the
  337. movea instruction would takes its immediate operand, 0xFFFF, sign extend
  338. it to 32 bits, 0xFFFFFFFF, and then add it into r6 giving 0xFFFEFFFF
  339. which is wrong (the fifth nibble is E). With the hi() pseudo op adding
  340. in the top bit of the lo() pseudo op, the movhi instruction actually
  341. stores 0 into r6 (0xFFFF + 1 = 0x0000), so that the movea instruction
  342. stores 0xFFFFFFFF into r6 - the right value.
  343. @cindex @code{hilo} pseudo-op, V850
  344. @item hilo()
  345. Computes the 32 bit value of the given expression and stores it into
  346. the immediate operand field of the given instruction (which must be a
  347. mov instruction). For example:
  348. @samp{mov hilo(here), r6}
  349. computes the absolute address of label 'here' and puts the result into
  350. register 6.
  351. @cindex @code{sdaoff} pseudo-op, V850
  352. @item sdaoff()
  353. Computes the offset of the named variable from the start of the Small
  354. Data Area (whoes address is held in register 4, the GP register) and
  355. stores the result as a 16 bit signed value in the immediate operand
  356. field of the given instruction. For example:
  357. @samp{ld.w sdaoff(_a_variable)[gp],r6}
  358. loads the contents of the location pointed to by the label '_a_variable'
  359. into register 6, provided that the label is located somewhere within +/-
  360. 32K of the address held in the GP register. [Note the linker assumes
  361. that the GP register contains a fixed address set to the address of the
  362. label called '__gp'. This can either be set up automatically by the
  363. linker, or specifically set by using the @samp{--defsym __gp=<value>}
  364. command line option].
  365. @cindex @code{tdaoff} pseudo-op, V850
  366. @item tdaoff()
  367. Computes the offset of the named variable from the start of the Tiny
  368. Data Area (whoes address is held in register 30, the EP register) and
  369. stores the result as a 4,5, 7 or 8 bit unsigned value in the immediate
  370. operand field of the given instruction. For example:
  371. @samp{sld.w tdaoff(_a_variable)[ep],r6}
  372. loads the contents of the location pointed to by the label '_a_variable'
  373. into register 6, provided that the label is located somewhere within +256
  374. bytes of the address held in the EP register. [Note the linker assumes
  375. that the EP register contains a fixed address set to the address of the
  376. label called '__ep'. This can either be set up automatically by the
  377. linker, or specifically set by using the @samp{--defsym __ep=<value>}
  378. command line option].
  379. @cindex @code{zdaoff} pseudo-op, V850
  380. @item zdaoff()
  381. Computes the offset of the named variable from address 0 and stores the
  382. result as a 16 bit signed value in the immediate operand field of the
  383. given instruction. For example:
  384. @samp{movea zdaoff(_a_variable),zero,r6}
  385. puts the address of the label '_a_variable' into register 6, assuming
  386. that the label is somewhere within the first 32K of memory. (Strictly
  387. speaking it also possible to access the last 32K of memory as well, as
  388. the offsets are signed).
  389. @cindex @code{ctoff} pseudo-op, V850
  390. @item ctoff()
  391. Computes the offset of the named variable from the start of the Call
  392. Table Area (whoes address is helg in system register 20, the CTBP
  393. register) and stores the result a 6 or 16 bit unsigned value in the
  394. immediate field of then given instruction or piece of data. For
  395. example:
  396. @samp{callt ctoff(table_func1)}
  397. will put the call the function whoes address is held in the call table
  398. at the location labeled 'table_func1'.
  399. @cindex @code{longcall} pseudo-op, V850
  400. @item .longcall @code{name}
  401. Indicates that the following sequence of instructions is a long call
  402. to function @code{name}. The linker will attempt to shorten this call
  403. sequence if @code{name} is within a 22bit offset of the call. Only
  404. valid if the @code{-mrelax} command line switch has been enabled.
  405. @cindex @code{longjump} pseudo-op, V850
  406. @item .longjump @code{name}
  407. Indicates that the following sequence of instructions is a long jump
  408. to label @code{name}. The linker will attempt to shorten this code
  409. sequence if @code{name} is within a 22bit offset of the jump. Only
  410. valid if the @code{-mrelax} command line switch has been enabled.
  411. @end table
  412. For information on the V850 instruction set, see @cite{V850
  413. Family 32-/16-Bit single-Chip Microcontroller Architecture Manual} from NEC.
  414. Ltd.