V850-Opcodes.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the GNU Assembler "as".
  4. Copyright (C) 1991-2017 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3
  7. or any later version published by the Free Software Foundation;
  8. with no Invariant Sections, with no Front-Cover Texts, and with no
  9. Back-Cover Texts. A copy of the license is included in the
  10. section entitled "GNU Free Documentation License".
  11. -->
  12. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <title>Using as: V850 Opcodes</title>
  15. <meta name="description" content="Using as: V850 Opcodes">
  16. <meta name="keywords" content="Using as: V850 Opcodes">
  17. <meta name="resource-type" content="document">
  18. <meta name="distribution" content="global">
  19. <meta name="Generator" content="makeinfo">
  20. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
  23. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  24. <link href="V850_002dDependent.html#V850_002dDependent" rel="up" title="V850-Dependent">
  25. <link href="Vax_002dDependent.html#Vax_002dDependent" rel="next" title="Vax-Dependent">
  26. <link href="V850-Directives.html#V850-Directives" rel="prev" title="V850 Directives">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.smallquotation {font-size: smaller}
  31. div.display {margin-left: 3.2em}
  32. div.example {margin-left: 3.2em}
  33. div.indentedblock {margin-left: 3.2em}
  34. div.lisp {margin-left: 3.2em}
  35. div.smalldisplay {margin-left: 3.2em}
  36. div.smallexample {margin-left: 3.2em}
  37. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  38. div.smalllisp {margin-left: 3.2em}
  39. kbd {font-style:oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. pre.smalldisplay {font-family: inherit; font-size: smaller}
  45. pre.smallexample {font-size: smaller}
  46. pre.smallformat {font-family: inherit; font-size: smaller}
  47. pre.smalllisp {font-size: smaller}
  48. span.nocodebreak {white-space:nowrap}
  49. span.nolinebreak {white-space:nowrap}
  50. span.roman {font-family:serif; font-weight:normal}
  51. span.sansserif {font-family:sans-serif; font-weight:normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  57. <a name="V850-Opcodes"></a>
  58. <div class="header">
  59. <p>
  60. Previous: <a href="V850-Directives.html#V850-Directives" accesskey="p" rel="prev">V850 Directives</a>, Up: <a href="V850_002dDependent.html#V850_002dDependent" accesskey="u" rel="up">V850-Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  61. </div>
  62. <hr>
  63. <a name="Opcodes-18"></a>
  64. <h4 class="subsection">9.48.5 Opcodes</h4>
  65. <a name="index-V850-opcodes"></a>
  66. <a name="index-opcodes-for-V850"></a>
  67. <p><code>as</code> implements all the standard V850 opcodes.
  68. </p>
  69. <p><code>as</code> also implements the following pseudo ops:
  70. </p>
  71. <dl compact="compact">
  72. <dd>
  73. <a name="index-hi0-pseudo_002dop_002c-V850"></a>
  74. </dd>
  75. <dt><code>hi0()</code></dt>
  76. <dd><p>Computes the higher 16 bits of the given expression and stores it into
  77. the immediate operand field of the given instruction. For example:
  78. </p>
  79. <p>&lsquo;<samp>mulhi hi0(here - there), r5, r6</samp>&rsquo;
  80. </p>
  81. <p>computes the difference between the address of labels &rsquo;here&rsquo; and
  82. &rsquo;there&rsquo;, takes the upper 16 bits of this difference, shifts it down 16
  83. bits and then multiplies it by the lower 16 bits in register 5, putting
  84. the result into register 6.
  85. </p>
  86. <a name="index-lo-pseudo_002dop_002c-V850"></a>
  87. </dd>
  88. <dt><code>lo()</code></dt>
  89. <dd><p>Computes the lower 16 bits of the given expression and stores it into
  90. the immediate operand field of the given instruction. For example:
  91. </p>
  92. <p>&lsquo;<samp>addi lo(here - there), r5, r6</samp>&rsquo;
  93. </p>
  94. <p>computes the difference between the address of labels &rsquo;here&rsquo; and
  95. &rsquo;there&rsquo;, takes the lower 16 bits of this difference and adds it to
  96. register 5, putting the result into register 6.
  97. </p>
  98. <a name="index-hi-pseudo_002dop_002c-V850"></a>
  99. </dd>
  100. <dt><code>hi()</code></dt>
  101. <dd><p>Computes the higher 16 bits of the given expression and then adds the
  102. value of the most significant bit of the lower 16 bits of the expression
  103. and stores the result into the immediate operand field of the given
  104. instruction. For example the following code can be used to compute the
  105. address of the label &rsquo;here&rsquo; and store it into register 6:
  106. </p>
  107. <p>&lsquo;<samp>movhi hi(here), r0, r6</samp>&rsquo;
  108. &lsquo;<samp>movea lo(here), r6, r6</samp>&rsquo;
  109. </p>
  110. <p>The reason for this special behaviour is that movea performs a sign
  111. extension on its immediate operand. So for example if the address of
  112. &rsquo;here&rsquo; was 0xFFFFFFFF then without the special behaviour of the hi()
  113. pseudo-op the movhi instruction would put 0xFFFF0000 into r6, then the
  114. movea instruction would takes its immediate operand, 0xFFFF, sign extend
  115. it to 32 bits, 0xFFFFFFFF, and then add it into r6 giving 0xFFFEFFFF
  116. which is wrong (the fifth nibble is E). With the hi() pseudo op adding
  117. in the top bit of the lo() pseudo op, the movhi instruction actually
  118. stores 0 into r6 (0xFFFF + 1 = 0x0000), so that the movea instruction
  119. stores 0xFFFFFFFF into r6 - the right value.
  120. </p>
  121. <a name="index-hilo-pseudo_002dop_002c-V850"></a>
  122. </dd>
  123. <dt><code>hilo()</code></dt>
  124. <dd><p>Computes the 32 bit value of the given expression and stores it into
  125. the immediate operand field of the given instruction (which must be a
  126. mov instruction). For example:
  127. </p>
  128. <p>&lsquo;<samp>mov hilo(here), r6</samp>&rsquo;
  129. </p>
  130. <p>computes the absolute address of label &rsquo;here&rsquo; and puts the result into
  131. register 6.
  132. </p>
  133. <a name="index-sdaoff-pseudo_002dop_002c-V850"></a>
  134. </dd>
  135. <dt><code>sdaoff()</code></dt>
  136. <dd><p>Computes the offset of the named variable from the start of the Small
  137. Data Area (whoes address is held in register 4, the GP register) and
  138. stores the result as a 16 bit signed value in the immediate operand
  139. field of the given instruction. For example:
  140. </p>
  141. <p>&lsquo;<samp>ld.w sdaoff(_a_variable)[gp],r6</samp>&rsquo;
  142. </p>
  143. <p>loads the contents of the location pointed to by the label &rsquo;_a_variable&rsquo;
  144. into register 6, provided that the label is located somewhere within +/-
  145. 32K of the address held in the GP register. [Note the linker assumes
  146. that the GP register contains a fixed address set to the address of the
  147. label called &rsquo;__gp&rsquo;. This can either be set up automatically by the
  148. linker, or specifically set by using the &lsquo;<samp>--defsym __gp=&lt;value&gt;</samp>&rsquo;
  149. command line option].
  150. </p>
  151. <a name="index-tdaoff-pseudo_002dop_002c-V850"></a>
  152. </dd>
  153. <dt><code>tdaoff()</code></dt>
  154. <dd><p>Computes the offset of the named variable from the start of the Tiny
  155. Data Area (whoes address is held in register 30, the EP register) and
  156. stores the result as a 4,5, 7 or 8 bit unsigned value in the immediate
  157. operand field of the given instruction. For example:
  158. </p>
  159. <p>&lsquo;<samp>sld.w tdaoff(_a_variable)[ep],r6</samp>&rsquo;
  160. </p>
  161. <p>loads the contents of the location pointed to by the label &rsquo;_a_variable&rsquo;
  162. into register 6, provided that the label is located somewhere within +256
  163. bytes of the address held in the EP register. [Note the linker assumes
  164. that the EP register contains a fixed address set to the address of the
  165. label called &rsquo;__ep&rsquo;. This can either be set up automatically by the
  166. linker, or specifically set by using the &lsquo;<samp>--defsym __ep=&lt;value&gt;</samp>&rsquo;
  167. command line option].
  168. </p>
  169. <a name="index-zdaoff-pseudo_002dop_002c-V850"></a>
  170. </dd>
  171. <dt><code>zdaoff()</code></dt>
  172. <dd><p>Computes the offset of the named variable from address 0 and stores the
  173. result as a 16 bit signed value in the immediate operand field of the
  174. given instruction. For example:
  175. </p>
  176. <p>&lsquo;<samp>movea zdaoff(_a_variable),zero,r6</samp>&rsquo;
  177. </p>
  178. <p>puts the address of the label &rsquo;_a_variable&rsquo; into register 6, assuming
  179. that the label is somewhere within the first 32K of memory. (Strictly
  180. speaking it also possible to access the last 32K of memory as well, as
  181. the offsets are signed).
  182. </p>
  183. <a name="index-ctoff-pseudo_002dop_002c-V850"></a>
  184. </dd>
  185. <dt><code>ctoff()</code></dt>
  186. <dd><p>Computes the offset of the named variable from the start of the Call
  187. Table Area (whoes address is helg in system register 20, the CTBP
  188. register) and stores the result a 6 or 16 bit unsigned value in the
  189. immediate field of then given instruction or piece of data. For
  190. example:
  191. </p>
  192. <p>&lsquo;<samp>callt ctoff(table_func1)</samp>&rsquo;
  193. </p>
  194. <p>will put the call the function whoes address is held in the call table
  195. at the location labeled &rsquo;table_func1&rsquo;.
  196. </p>
  197. <a name="index-longcall-pseudo_002dop_002c-V850"></a>
  198. </dd>
  199. <dt><code>.longcall <code>name</code></code></dt>
  200. <dd><p>Indicates that the following sequence of instructions is a long call
  201. to function <code>name</code>. The linker will attempt to shorten this call
  202. sequence if <code>name</code> is within a 22bit offset of the call. Only
  203. valid if the <code>-mrelax</code> command line switch has been enabled.
  204. </p>
  205. <a name="index-longjump-pseudo_002dop_002c-V850"></a>
  206. </dd>
  207. <dt><code>.longjump <code>name</code></code></dt>
  208. <dd><p>Indicates that the following sequence of instructions is a long jump
  209. to label <code>name</code>. The linker will attempt to shorten this code
  210. sequence if <code>name</code> is within a 22bit offset of the jump. Only
  211. valid if the <code>-mrelax</code> command line switch has been enabled.
  212. </p>
  213. </dd>
  214. </dl>
  215. <p>For information on the V850 instruction set, see <cite>V850
  216. Family 32-/16-Bit single-Chip Microcontroller Architecture Manual</cite> from NEC.
  217. Ltd.
  218. </p>
  219. <hr>
  220. <div class="header">
  221. <p>
  222. Previous: <a href="V850-Directives.html#V850-Directives" accesskey="p" rel="prev">V850 Directives</a>, Up: <a href="V850_002dDependent.html#V850_002dDependent" accesskey="u" rel="up">V850-Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
  223. </div>
  224. </body>
  225. </html>