If.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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: If</title>
  15. <meta name="description" content="Using as: If">
  16. <meta name="keywords" content="Using as: If">
  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="Pseudo-Ops.html#Pseudo-Ops" rel="up" title="Pseudo Ops">
  25. <link href="Incbin.html#Incbin" rel="next" title="Incbin">
  26. <link href="Ident.html#Ident" rel="prev" title="Ident">
  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="If"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Incbin.html#Incbin" accesskey="n" rel="next">Incbin</a>, Previous: <a href="Ident.html#Ident" accesskey="p" rel="prev">Ident</a>, Up: <a href="Pseudo-Ops.html#Pseudo-Ops" accesskey="u" rel="up">Pseudo Ops</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="g_t_002eif-absolute-expression"></a>
  64. <h3 class="section">7.41 <code>.if <var>absolute expression</var></code></h3>
  65. <a name="index-conditional-assembly"></a>
  66. <a name="index-if-directive"></a>
  67. <p><code>.if</code> marks the beginning of a section of code which is only
  68. considered part of the source program being assembled if the argument
  69. (which must be an <var>absolute expression</var>) is non-zero. The end of
  70. the conditional section of code must be marked by <code>.endif</code>
  71. (see <a href="Endif.html#Endif"><code>.endif</code></a>); optionally, you may include code for the
  72. alternative condition, flagged by <code>.else</code> (see <a href="Else.html#Else"><code>.else</code></a>).
  73. If you have several conditions to check, <code>.elseif</code> may be used to avoid
  74. nesting blocks if/else within each subsequent <code>.else</code> block.
  75. </p>
  76. <p>The following variants of <code>.if</code> are also supported:
  77. </p><dl compact="compact">
  78. <dd><a name="index-ifdef-directive"></a>
  79. </dd>
  80. <dt><code>.ifdef <var>symbol</var></code></dt>
  81. <dd><p>Assembles the following section of code if the specified <var>symbol</var>
  82. has been defined. Note a symbol which has been referenced but not yet defined
  83. is considered to be undefined.
  84. </p>
  85. <a name="index-ifb-directive"></a>
  86. </dd>
  87. <dt><code>.ifb <var>text</var></code></dt>
  88. <dd><p>Assembles the following section of code if the operand is blank (empty).
  89. </p>
  90. <a name="index-ifc-directive"></a>
  91. </dd>
  92. <dt><code>.ifc <var>string1</var>,<var>string2</var></code></dt>
  93. <dd><p>Assembles the following section of code if the two strings are the same. The
  94. strings may be optionally quoted with single quotes. If they are not quoted,
  95. the first string stops at the first comma, and the second string stops at the
  96. end of the line. Strings which contain whitespace should be quoted. The
  97. string comparison is case sensitive.
  98. </p>
  99. <a name="index-ifeq-directive"></a>
  100. </dd>
  101. <dt><code>.ifeq <var>absolute expression</var></code></dt>
  102. <dd><p>Assembles the following section of code if the argument is zero.
  103. </p>
  104. <a name="index-ifeqs-directive"></a>
  105. </dd>
  106. <dt><code>.ifeqs <var>string1</var>,<var>string2</var></code></dt>
  107. <dd><p>Another form of <code>.ifc</code>. The strings must be quoted using double quotes.
  108. </p>
  109. <a name="index-ifge-directive"></a>
  110. </dd>
  111. <dt><code>.ifge <var>absolute expression</var></code></dt>
  112. <dd><p>Assembles the following section of code if the argument is greater than or
  113. equal to zero.
  114. </p>
  115. <a name="index-ifgt-directive"></a>
  116. </dd>
  117. <dt><code>.ifgt <var>absolute expression</var></code></dt>
  118. <dd><p>Assembles the following section of code if the argument is greater than zero.
  119. </p>
  120. <a name="index-ifle-directive"></a>
  121. </dd>
  122. <dt><code>.ifle <var>absolute expression</var></code></dt>
  123. <dd><p>Assembles the following section of code if the argument is less than or equal
  124. to zero.
  125. </p>
  126. <a name="index-iflt-directive"></a>
  127. </dd>
  128. <dt><code>.iflt <var>absolute expression</var></code></dt>
  129. <dd><p>Assembles the following section of code if the argument is less than zero.
  130. </p>
  131. <a name="index-ifnb-directive"></a>
  132. </dd>
  133. <dt><code>.ifnb <var>text</var></code></dt>
  134. <dd><p>Like <code>.ifb</code>, but the sense of the test is reversed: this assembles the
  135. following section of code if the operand is non-blank (non-empty).
  136. </p>
  137. <a name="index-ifnc-directive"></a>
  138. </dd>
  139. <dt><code>.ifnc <var>string1</var>,<var>string2</var>.</code></dt>
  140. <dd><p>Like <code>.ifc</code>, but the sense of the test is reversed: this assembles the
  141. following section of code if the two strings are not the same.
  142. </p>
  143. <a name="index-ifndef-directive"></a>
  144. <a name="index-ifnotdef-directive"></a>
  145. </dd>
  146. <dt><code>.ifndef <var>symbol</var></code></dt>
  147. <dt><code>.ifnotdef <var>symbol</var></code></dt>
  148. <dd><p>Assembles the following section of code if the specified <var>symbol</var>
  149. has not been defined. Both spelling variants are equivalent. Note a symbol
  150. which has been referenced but not yet defined is considered to be undefined.
  151. </p>
  152. <a name="index-ifne-directive"></a>
  153. </dd>
  154. <dt><code>.ifne <var>absolute expression</var></code></dt>
  155. <dd><p>Assembles the following section of code if the argument is not equal to zero
  156. (in other words, this is equivalent to <code>.if</code>).
  157. </p>
  158. <a name="index-ifnes-directive"></a>
  159. </dd>
  160. <dt><code>.ifnes <var>string1</var>,<var>string2</var></code></dt>
  161. <dd><p>Like <code>.ifeqs</code>, but the sense of the test is reversed: this assembles the
  162. following section of code if the two strings are not the same.
  163. </p></dd>
  164. </dl>
  165. <hr>
  166. <div class="header">
  167. <p>
  168. Next: <a href="Incbin.html#Incbin" accesskey="n" rel="next">Incbin</a>, Previous: <a href="Ident.html#Ident" accesskey="p" rel="prev">Ident</a>, Up: <a href="Pseudo-Ops.html#Pseudo-Ops" accesskey="u" rel="up">Pseudo Ops</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>
  169. </div>
  170. </body>
  171. </html>