blob: 989be76861679c3227541bfd5be6d71358984796 [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, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2006, 2007, 2008, 2009, 2010 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>
<link rel="stylesheet" type="text/css" href="../cs.css">
</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.60 <code>.if </code><var>absolute expression</var></h3>
<p><a name="index-conditional-assembly-346"></a><a name="index-g_t_0040code_007bif_007d-directive-347"></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-348"></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-349"></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-350"></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-351"></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-352"></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-353"></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-354"></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-355"></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-356"></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-357"></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-358"></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-359"></a><a name="index-g_t_0040code_007bifnotdef_007d-directive-360"></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-361"></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-362"></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>