M32R_002dDirectives.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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: M32R-Directives</title>
  15. <meta name="description" content="Using as: M32R-Directives">
  16. <meta name="keywords" content="Using as: M32R-Directives">
  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="M32R_002dDependent.html#M32R_002dDependent" rel="up" title="M32R-Dependent">
  25. <link href="M32R_002dWarnings.html#M32R_002dWarnings" rel="next" title="M32R-Warnings">
  26. <link href="M32R_002dOpts.html#M32R_002dOpts" rel="prev" title="M32R-Opts">
  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="M32R_002dDirectives"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="M32R_002dWarnings.html#M32R_002dWarnings" accesskey="n" rel="next">M32R-Warnings</a>, Previous: <a href="M32R_002dOpts.html#M32R_002dOpts" accesskey="p" rel="prev">M32R-Opts</a>, Up: <a href="M32R_002dDependent.html#M32R_002dDependent" accesskey="u" rel="up">M32R-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="M32R-Directives"></a>
  64. <h4 class="subsection">9.22.2 M32R Directives</h4>
  65. <a name="index-directives_002c-M32R"></a>
  66. <a name="index-M32R-directives"></a>
  67. <p>The Renease M32R version of <code>as</code> has a few architecture
  68. specific directives:
  69. </p>
  70. <dl compact="compact">
  71. <dd>
  72. <a name="index-low-directive_002c-M32R"></a>
  73. </dd>
  74. <dt><code>low <var>expression</var></code></dt>
  75. <dd><p>The <code>low</code> directive computes the value of its expression and
  76. places the lower 16-bits of the result into the immediate-field of the
  77. instruction. For example:
  78. </p>
  79. <div class="smallexample">
  80. <pre class="smallexample"> or3 r0, r0, #low(0x12345678) ; compute r0 = r0 | 0x5678
  81. add3, r0, r0, #low(fred) ; compute r0 = r0 + low 16-bits of address of fred
  82. </pre></div>
  83. </dd>
  84. <dt><code>high <var>expression</var></code></dt>
  85. <dd><a name="index-high-directive_002c-M32R"></a>
  86. <p>The <code>high</code> directive computes the value of its expression and
  87. places the upper 16-bits of the result into the immediate-field of the
  88. instruction. For example:
  89. </p>
  90. <div class="smallexample">
  91. <pre class="smallexample"> seth r0, #high(0x12345678) ; compute r0 = 0x12340000
  92. seth, r0, #high(fred) ; compute r0 = upper 16-bits of address of fred
  93. </pre></div>
  94. </dd>
  95. <dt><code>shigh <var>expression</var></code></dt>
  96. <dd><a name="index-shigh-directive_002c-M32R"></a>
  97. <p>The <code>shigh</code> directive is very similar to the <code>high</code>
  98. directive. It also computes the value of its expression and places
  99. the upper 16-bits of the result into the immediate-field of the
  100. instruction. The difference is that <code>shigh</code> also checks to see
  101. if the lower 16-bits could be interpreted as a signed number, and if
  102. so it assumes that a borrow will occur from the upper-16 bits. To
  103. compensate for this the <code>shigh</code> directive pre-biases the upper
  104. 16 bit value by adding one to it. For example:
  105. </p>
  106. <p>For example:
  107. </p>
  108. <div class="smallexample">
  109. <pre class="smallexample"> seth r0, #shigh(0x12345678) ; compute r0 = 0x12340000
  110. seth r0, #shigh(0x00008000) ; compute r0 = 0x00010000
  111. </pre></div>
  112. <p>In the second example the lower 16-bits are 0x8000. If these are
  113. treated as a signed value and sign extended to 32-bits then the value
  114. becomes 0xffff8000. If this value is then added to 0x00010000 then
  115. the result is 0x00008000.
  116. </p>
  117. <p>This behaviour is to allow for the different semantics of the
  118. <code>or3</code> and <code>add3</code> instructions. The <code>or3</code> instruction
  119. treats its 16-bit immediate argument as unsigned whereas the
  120. <code>add3</code> treats its 16-bit immediate as a signed value. So for
  121. example:
  122. </p>
  123. <div class="smallexample">
  124. <pre class="smallexample"> seth r0, #shigh(0x00008000)
  125. add3 r0, r0, #low(0x00008000)
  126. </pre></div>
  127. <p>Produces the correct result in r0, whereas:
  128. </p>
  129. <div class="smallexample">
  130. <pre class="smallexample"> seth r0, #shigh(0x00008000)
  131. or3 r0, r0, #low(0x00008000)
  132. </pre></div>
  133. <p>Stores 0xffff8000 into r0.
  134. </p>
  135. <p>Note - the <code>shigh</code> directive does not know where in the assembly
  136. source code the lower 16-bits of the value are going set, so it cannot
  137. check to make sure that an <code>or3</code> instruction is being used rather
  138. than an <code>add3</code> instruction. It is up to the programmer to make
  139. sure that correct directives are used.
  140. </p>
  141. <a name="index-_002em32r-directive_002c-M32R"></a>
  142. </dd>
  143. <dt><code>.m32r</code></dt>
  144. <dd><p>The directive performs a similar thing as the <em>-m32r</em> command
  145. line option. It tells the assembler to only accept M32R instructions
  146. from now on. An instructions from later M32R architectures are
  147. refused.
  148. </p>
  149. <a name="index-_002em32rx-directive_002c-M32RX"></a>
  150. </dd>
  151. <dt><code>.m32rx</code></dt>
  152. <dd><p>The directive performs a similar thing as the <em>-m32rx</em> command
  153. line option. It tells the assembler to start accepting the extra
  154. instructions in the M32RX ISA as well as the ordinary M32R ISA.
  155. </p>
  156. <a name="index-_002em32r2-directive_002c-M32R2"></a>
  157. </dd>
  158. <dt><code>.m32r2</code></dt>
  159. <dd><p>The directive performs a similar thing as the <em>-m32r2</em> command
  160. line option. It tells the assembler to start accepting the extra
  161. instructions in the M32R2 ISA as well as the ordinary M32R ISA.
  162. </p>
  163. <a name="index-_002elittle-directive_002c-M32RX"></a>
  164. </dd>
  165. <dt><code>.little</code></dt>
  166. <dd><p>The directive performs a similar thing as the <em>-little</em> command
  167. line option. It tells the assembler to start producing little-endian
  168. code and data. This option should be used with care as producing
  169. mixed-endian binary files is fraught with danger.
  170. </p>
  171. <a name="index-_002ebig-directive_002c-M32RX"></a>
  172. </dd>
  173. <dt><code>.big</code></dt>
  174. <dd><p>The directive performs a similar thing as the <em>-big</em> command
  175. line option. It tells the assembler to start producing big-endian
  176. code and data. This option should be used with care as producing
  177. mixed-endian binary files is fraught with danger.
  178. </p>
  179. </dd>
  180. </dl>
  181. <hr>
  182. <div class="header">
  183. <p>
  184. Next: <a href="M32R_002dWarnings.html#M32R_002dWarnings" accesskey="n" rel="next">M32R-Warnings</a>, Previous: <a href="M32R_002dOpts.html#M32R_002dOpts" accesskey="p" rel="prev">M32R-Opts</a>, Up: <a href="M32R_002dDependent.html#M32R_002dDependent" accesskey="u" rel="up">M32R-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>
  185. </div>
  186. </body>
  187. </html>