Infix-Ops.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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: Infix Ops</title>
  15. <meta name="description" content="Using as: Infix Ops">
  16. <meta name="keywords" content="Using as: Infix Ops">
  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="Integer-Exprs.html#Integer-Exprs" rel="up" title="Integer Exprs">
  25. <link href="Pseudo-Ops.html#Pseudo-Ops" rel="next" title="Pseudo Ops">
  26. <link href="Prefix-Ops.html#Prefix-Ops" rel="prev" title="Prefix Ops">
  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="Infix-Ops"></a>
  58. <div class="header">
  59. <p>
  60. Previous: <a href="Prefix-Ops.html#Prefix-Ops" accesskey="p" rel="prev">Prefix Ops</a>, Up: <a href="Integer-Exprs.html#Integer-Exprs" accesskey="u" rel="up">Integer Exprs</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="Infix-Operators"></a>
  64. <h4 class="subsection">6.2.4 Infix Operators</h4>
  65. <a name="index-infix-operators"></a>
  66. <a name="index-operators_002c-permitted-arguments"></a>
  67. <p><em>Infix operators</em> take two arguments, one on either side. Operators
  68. have precedence, but operations with equal precedence are performed left
  69. to right. Apart from <code>+</code> or <samp>-</samp>, both arguments must be
  70. absolute, and the result is absolute.
  71. </p>
  72. <ol>
  73. <li><a name="index-operator-precedence"></a>
  74. <a name="index-precedence-of-operators"></a>
  75. </li><li> Highest Precedence
  76. <dl compact="compact">
  77. <dt><code>*</code></dt>
  78. <dd><p><em>Multiplication</em>.
  79. </p>
  80. </dd>
  81. <dt><code>/</code></dt>
  82. <dd><p><em>Division</em>. Truncation is the same as the C operator &lsquo;<samp>/</samp>&rsquo;
  83. </p>
  84. </dd>
  85. <dt><code>%</code></dt>
  86. <dd><p><em>Remainder</em>.
  87. </p>
  88. </dd>
  89. <dt><code>&lt;&lt;</code></dt>
  90. <dd><p><em>Shift Left</em>. Same as the C operator &lsquo;<samp>&lt;&lt;</samp>&rsquo;.
  91. </p>
  92. </dd>
  93. <dt><code>&gt;&gt;</code></dt>
  94. <dd><p><em>Shift Right</em>. Same as the C operator &lsquo;<samp>&gt;&gt;</samp>&rsquo;.
  95. </p></dd>
  96. </dl>
  97. </li><li> Intermediate precedence
  98. <dl compact="compact">
  99. <dt><code>|</code></dt>
  100. <dd>
  101. <p><em>Bitwise Inclusive Or</em>.
  102. </p>
  103. </dd>
  104. <dt><code>&amp;</code></dt>
  105. <dd><p><em>Bitwise And</em>.
  106. </p>
  107. </dd>
  108. <dt><code>^</code></dt>
  109. <dd><p><em>Bitwise Exclusive Or</em>.
  110. </p>
  111. </dd>
  112. <dt><code>!</code></dt>
  113. <dd><p><em>Bitwise Or Not</em>.
  114. </p></dd>
  115. </dl>
  116. </li><li> Low Precedence
  117. <dl compact="compact">
  118. <dd><a name="index-addition_002c-permitted-arguments"></a>
  119. <a name="index-plus_002c-permitted-arguments"></a>
  120. <a name="index-arguments-for-addition"></a>
  121. </dd>
  122. <dt><code>+</code></dt>
  123. <dd><p><em>Addition</em>. If either argument is absolute, the result has the section of
  124. the other argument. You may not add together arguments from different
  125. sections.
  126. </p>
  127. <a name="index-subtraction_002c-permitted-arguments"></a>
  128. <a name="index-minus_002c-permitted-arguments"></a>
  129. <a name="index-arguments-for-subtraction"></a>
  130. </dd>
  131. <dt><code>-</code></dt>
  132. <dd><p><em>Subtraction</em>. If the right argument is absolute, the
  133. result has the section of the left argument.
  134. If both arguments are in the same section, the result is absolute.
  135. You may not subtract arguments from different sections.
  136. </p>
  137. <a name="index-comparison-expressions"></a>
  138. <a name="index-expressions_002c-comparison"></a>
  139. </dd>
  140. <dt><code>==</code></dt>
  141. <dd><p><em>Is Equal To</em>
  142. </p></dd>
  143. <dt><code>&lt;&gt;</code></dt>
  144. <dt><code>!=</code></dt>
  145. <dd><p><em>Is Not Equal To</em>
  146. </p></dd>
  147. <dt><code>&lt;</code></dt>
  148. <dd><p><em>Is Less Than</em>
  149. </p></dd>
  150. <dt><code>&gt;</code></dt>
  151. <dd><p><em>Is Greater Than</em>
  152. </p></dd>
  153. <dt><code>&gt;=</code></dt>
  154. <dd><p><em>Is Greater Than Or Equal To</em>
  155. </p></dd>
  156. <dt><code>&lt;=</code></dt>
  157. <dd><p><em>Is Less Than Or Equal To</em>
  158. </p>
  159. <p>The comparison operators can be used as infix operators. A true results has a
  160. value of -1 whereas a false result has a value of 0. Note, these operators
  161. perform signed comparisons.
  162. </p></dd>
  163. </dl>
  164. </li><li> Lowest Precedence
  165. <dl compact="compact">
  166. <dt><code>&amp;&amp;</code></dt>
  167. <dd><p><em>Logical And</em>.
  168. </p>
  169. </dd>
  170. <dt><code>||</code></dt>
  171. <dd><p><em>Logical Or</em>.
  172. </p>
  173. <p>These two logical operations can be used to combine the results of sub
  174. expressions. Note, unlike the comparison operators a true result returns a
  175. value of 1 but a false results does still return 0. Also note that the logical
  176. or operator has a slightly lower precedence than logical and.
  177. </p>
  178. </dd>
  179. </dl>
  180. </li></ol>
  181. <p>In short, it&rsquo;s only meaningful to add or subtract the <em>offsets</em> in an
  182. address; you can only have a defined section in one of the two arguments.
  183. </p>
  184. <hr>
  185. <div class="header">
  186. <p>
  187. Previous: <a href="Prefix-Ops.html#Prefix-Ops" accesskey="p" rel="prev">Prefix Ops</a>, Up: <a href="Integer-Exprs.html#Integer-Exprs" accesskey="u" rel="up">Integer Exprs</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>
  188. </div>
  189. </body>
  190. </html>