blob: 7a75040ec367870089ba3f026b8dc814260b6f80 [file] [log] [blame]
<html lang="en">
<head>
<title>If - Using as</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using as">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Pseudo-Ops.html#Pseudo-Ops" title="Pseudo Ops">
<link rel="prev" href="Ident.html#Ident" title="Ident">
<link rel="next" href="Incbin.html#Incbin" title="Incbin">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This file documents the GNU Assembler "as".
Copyright (C) 1991-2019 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the
section entitled ``GNU Free Documentation License''.
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="If"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Incbin.html#Incbin">Incbin</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Ident.html#Ident">Ident</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Pseudo-Ops.html#Pseudo-Ops">Pseudo Ops</a>
<hr>
</div>
<h3 class="section">7.44 <code>.if </code><var>absolute expression</var></h3>
<p><a name="index-conditional-assembly-361"></a><a name="index-g_t_0040code_007bif_007d-directive-362"></a><code>.if</code> marks the beginning of a section of code which is only
considered part of the source program being assembled if the argument
(which must be an <var>absolute expression</var>) is non-zero. The end of
the conditional section of code must be marked by <code>.endif</code>
(see <a href="Endif.html#Endif"><code>.endif</code></a>); optionally, you may include code for the
alternative condition, flagged by <code>.else</code> (see <a href="Else.html#Else"><code>.else</code></a>).
If you have several conditions to check, <code>.elseif</code> may be used to avoid
nesting blocks if/else within each subsequent <code>.else</code> block.
<p>The following variants of <code>.if</code> are also supported:
<a name="index-g_t_0040code_007bifdef_007d-directive-363"></a>
<dl><dt><code>.ifdef </code><var>symbol</var><dd>Assembles the following section of code if the specified <var>symbol</var>
has been defined. Note a symbol which has been referenced but not yet defined
is considered to be undefined.
<p><a name="index-g_t_0040code_007bifb_007d-directive-364"></a><br><dt><code>.ifb </code><var>text</var><dd>Assembles the following section of code if the operand is blank (empty).
<p><a name="index-g_t_0040code_007bifc_007d-directive-365"></a><br><dt><code>.ifc </code><var>string1</var><code>,</code><var>string2</var><dd>Assembles the following section of code if the two strings are the same. The
strings may be optionally quoted with single quotes. If they are not quoted,
the first string stops at the first comma, and the second string stops at the
end of the line. Strings which contain whitespace should be quoted. The
string comparison is case sensitive.
<p><a name="index-g_t_0040code_007bifeq_007d-directive-366"></a><br><dt><code>.ifeq </code><var>absolute expression</var><dd>Assembles the following section of code if the argument is zero.
<p><a name="index-g_t_0040code_007bifeqs_007d-directive-367"></a><br><dt><code>.ifeqs </code><var>string1</var><code>,</code><var>string2</var><dd>Another form of <code>.ifc</code>. The strings must be quoted using double quotes.
<p><a name="index-g_t_0040code_007bifge_007d-directive-368"></a><br><dt><code>.ifge </code><var>absolute expression</var><dd>Assembles the following section of code if the argument is greater than or
equal to zero.
<p><a name="index-g_t_0040code_007bifgt_007d-directive-369"></a><br><dt><code>.ifgt </code><var>absolute expression</var><dd>Assembles the following section of code if the argument is greater than zero.
<p><a name="index-g_t_0040code_007bifle_007d-directive-370"></a><br><dt><code>.ifle </code><var>absolute expression</var><dd>Assembles the following section of code if the argument is less than or equal
to zero.
<p><a name="index-g_t_0040code_007biflt_007d-directive-371"></a><br><dt><code>.iflt </code><var>absolute expression</var><dd>Assembles the following section of code if the argument is less than zero.
<p><a name="index-g_t_0040code_007bifnb_007d-directive-372"></a><br><dt><code>.ifnb </code><var>text</var><dd>Like <code>.ifb</code>, but the sense of the test is reversed: this assembles the
following section of code if the operand is non-blank (non-empty).
<p><a name="index-g_t_0040code_007bifnc_007d-directive-373"></a><br><dt><code>.ifnc </code><var>string1</var><code>,</code><var>string2</var><code>.</code><dd>Like <code>.ifc</code>, but the sense of the test is reversed: this assembles the
following section of code if the two strings are not the same.
<p><a name="index-g_t_0040code_007bifndef_007d-directive-374"></a><a name="index-g_t_0040code_007bifnotdef_007d-directive-375"></a><br><dt><code>.ifndef </code><var>symbol</var><dt><code>.ifnotdef </code><var>symbol</var><dd>Assembles the following section of code if the specified <var>symbol</var>
has not been defined. Both spelling variants are equivalent. Note a symbol
which has been referenced but not yet defined is considered to be undefined.
<p><a name="index-g_t_0040code_007bifne_007d-directive-376"></a><br><dt><code>.ifne </code><var>absolute expression</var><dd>Assembles the following section of code if the argument is not equal to zero
(in other words, this is equivalent to <code>.if</code>).
<p><a name="index-g_t_0040code_007bifnes_007d-directive-377"></a><br><dt><code>.ifnes </code><var>string1</var><code>,</code><var>string2</var><dd>Like <code>.ifeqs</code>, but the sense of the test is reversed: this assembles the
following section of code if the two strings are not the same.
</dl>
</body></html>