M32C_002dModifiers.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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: M32C-Modifiers</title>
  15. <meta name="description" content="Using as: M32C-Modifiers">
  16. <meta name="keywords" content="Using as: M32C-Modifiers">
  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="M32C_002dSyntax.html#M32C_002dSyntax" rel="up" title="M32C-Syntax">
  25. <link href="M32C_002dChars.html#M32C_002dChars" rel="next" title="M32C-Chars">
  26. <link href="M32C_002dSyntax.html#M32C_002dSyntax" rel="prev" title="M32C-Syntax">
  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="M32C_002dModifiers"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="M32C_002dChars.html#M32C_002dChars" accesskey="n" rel="next">M32C-Chars</a>, Up: <a href="M32C_002dSyntax.html#M32C_002dSyntax" accesskey="u" rel="up">M32C-Syntax</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="Symbolic-Operand-Modifiers"></a>
  64. <h4 class="subsubsection">9.21.2.1 Symbolic Operand Modifiers</h4>
  65. <a name="index-M32C-modifiers"></a>
  66. <a name="index-modifiers_002c-M32C"></a>
  67. <p>The assembler supports several modifiers when using symbol addresses
  68. in M32C instruction operands. The general syntax is the following:
  69. </p>
  70. <div class="smallexample">
  71. <pre class="smallexample">%modifier(symbol)
  72. </pre></div>
  73. <dl compact="compact">
  74. <dd><a name="index-symbol-modifiers-2"></a>
  75. </dd>
  76. <dt><code>%dsp8</code></dt>
  77. <dt><code>%dsp16</code></dt>
  78. <dd>
  79. <p>These modifiers override the assembler&rsquo;s assumptions about how big a
  80. symbol&rsquo;s address is. Normally, when it sees an operand like
  81. &lsquo;<samp>sym[a0]</samp>&rsquo; it assumes &lsquo;<samp>sym</samp>&rsquo; may require the widest
  82. displacement field (16 bits for &lsquo;<samp>-m16c</samp>&rsquo;, 24 bits for
  83. &lsquo;<samp>-m32c</samp>&rsquo;). These modifiers tell it to assume the address will fit
  84. in an 8 or 16 bit (respectively) unsigned displacement. Note that, of
  85. course, if it doesn&rsquo;t actually fit you will get linker errors. Example:
  86. </p>
  87. <div class="smallexample">
  88. <pre class="smallexample">mov.w %dsp8(sym)[a0],r1
  89. mov.b #0,%dsp8(sym)[a0]
  90. </pre></div>
  91. </dd>
  92. <dt><code>%hi8</code></dt>
  93. <dd>
  94. <p>This modifier allows you to load bits 16 through 23 of a 24 bit
  95. address into an 8 bit register. This is useful with, for example, the
  96. M16C &lsquo;<samp>smovf</samp>&rsquo; instruction, which expects a 20 bit address in
  97. &lsquo;<samp>r1h</samp>&rsquo; and &lsquo;<samp>a0</samp>&rsquo;. Example:
  98. </p>
  99. <div class="smallexample">
  100. <pre class="smallexample">mov.b #%hi8(sym),r1h
  101. mov.w #%lo16(sym),a0
  102. smovf.b
  103. </pre></div>
  104. </dd>
  105. <dt><code>%lo16</code></dt>
  106. <dd>
  107. <p>Likewise, this modifier allows you to load bits 0 through 15 of a 24
  108. bit address into a 16 bit register.
  109. </p>
  110. </dd>
  111. <dt><code>%hi16</code></dt>
  112. <dd>
  113. <p>This modifier allows you to load bits 16 through 31 of a 32 bit
  114. address into a 16 bit register. While the M32C family only has 24
  115. bits of address space, it does support addresses in pairs of 16 bit
  116. registers (like &lsquo;<samp>a1a0</samp>&rsquo; for the &lsquo;<samp>lde</samp>&rsquo; instruction). This
  117. modifier is for loading the upper half in such cases. Example:
  118. </p>
  119. <div class="smallexample">
  120. <pre class="smallexample">mov.w #%hi16(sym),a1
  121. mov.w #%lo16(sym),a0
  122. &hellip;
  123. lde.w [a1a0],r1
  124. </pre></div>
  125. </dd>
  126. </dl>
  127. <hr>
  128. <div class="header">
  129. <p>
  130. Next: <a href="M32C_002dChars.html#M32C_002dChars" accesskey="n" rel="next">M32C-Chars</a>, Up: <a href="M32C_002dSyntax.html#M32C_002dSyntax" accesskey="u" rel="up">M32C-Syntax</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>
  131. </div>
  132. </body>
  133. </html>