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 5Copyright (C) 1991-2021 Free Software Foundation, Inc. 6 7Permission is granted to copy, distribute and/or modify this document 8under the terms of the GNU Free Documentation License, Version 1.3 9or any later version published by the Free Software Foundation; 10with no Invariant Sections, with no Front-Cover Texts, and with no 11Back-Cover Texts. A copy of the license is included in the 12section entitled "GNU Free Documentation License". 13 --> 14<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 15<head> 16<title>Using as: If</title> 17 18<meta name="description" content="Using as: If"> 19<meta name="keywords" content="Using as: If"> 20<meta name="resource-type" content="document"> 21<meta name="distribution" content="global"> 22<meta name="Generator" content="makeinfo"> 23<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 24<link href="index.html#Top" rel="start" title="Top"> 25<link href="AS-Index.html#AS-Index" rel="index" title="AS Index"> 26<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 27<link href="Pseudo-Ops.html#Pseudo-Ops" rel="up" title="Pseudo Ops"> 28<link href="Incbin.html#Incbin" rel="next" title="Incbin"> 29<link href="Ident.html#Ident" rel="previous" title="Ident"> 30<style type="text/css"> 31<!-- 32a.summary-letter {text-decoration: none} 33blockquote.smallquotation {font-size: smaller} 34div.display {margin-left: 3.2em} 35div.example {margin-left: 3.2em} 36div.indentedblock {margin-left: 3.2em} 37div.lisp {margin-left: 3.2em} 38div.smalldisplay {margin-left: 3.2em} 39div.smallexample {margin-left: 3.2em} 40div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 41div.smalllisp {margin-left: 3.2em} 42kbd {font-style:oblique} 43pre.display {font-family: inherit} 44pre.format {font-family: inherit} 45pre.menu-comment {font-family: serif} 46pre.menu-preformatted {font-family: serif} 47pre.smalldisplay {font-family: inherit; font-size: smaller} 48pre.smallexample {font-size: smaller} 49pre.smallformat {font-family: inherit; font-size: smaller} 50pre.smalllisp {font-size: smaller} 51span.nocodebreak {white-space:nowrap} 52span.nolinebreak {white-space:nowrap} 53span.roman {font-family:serif; font-weight:normal} 54span.sansserif {font-family:sans-serif; font-weight:normal} 55ul.no-bullet {list-style: none} 56--> 57</style> 58 59 60</head> 61 62<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 63<a name="If"></a> 64<div class="header"> 65<p> 66Next: <a href="Incbin.html#Incbin" accesskey="n" rel="next">Incbin</a>, Previous: <a href="Ident.html#Ident" accesskey="p" rel="previous">Ident</a>, Up: <a href="Pseudo-Ops.html#Pseudo-Ops" accesskey="u" rel="up">Pseudo Ops</a> [<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> 67</div> 68<hr> 69<a name="g_t_002eif-absolute-expression"></a> 70<h3 class="section">7.45 <code>.if <var>absolute expression</var></code></h3> 71 72<a name="index-conditional-assembly"></a> 73<a name="index-if-directive"></a> 74<p><code>.if</code> marks the beginning of a section of code which is only 75considered part of the source program being assembled if the argument 76(which must be an <var>absolute expression</var>) is non-zero. The end of 77the conditional section of code must be marked by <code>.endif</code> 78(see <a href="Endif.html#Endif"><code>.endif</code></a>); optionally, you may include code for the 79alternative condition, flagged by <code>.else</code> (see <a href="Else.html#Else"><code>.else</code></a>). 80If you have several conditions to check, <code>.elseif</code> may be used to avoid 81nesting blocks if/else within each subsequent <code>.else</code> block. 82</p> 83<p>The following variants of <code>.if</code> are also supported: 84</p><dl compact="compact"> 85<dd><a name="index-ifdef-directive"></a> 86</dd> 87<dt><code>.ifdef <var>symbol</var></code></dt> 88<dd><p>Assembles the following section of code if the specified <var>symbol</var> 89has been defined. Note a symbol which has been referenced but not yet defined 90is considered to be undefined. 91</p> 92<a name="index-ifb-directive"></a> 93</dd> 94<dt><code>.ifb <var>text</var></code></dt> 95<dd><p>Assembles the following section of code if the operand is blank (empty). 96</p> 97<a name="index-ifc-directive"></a> 98</dd> 99<dt><code>.ifc <var>string1</var>,<var>string2</var></code></dt> 100<dd><p>Assembles the following section of code if the two strings are the same. The 101strings may be optionally quoted with single quotes. If they are not quoted, 102the first string stops at the first comma, and the second string stops at the 103end of the line. Strings which contain whitespace should be quoted. The 104string comparison is case sensitive. 105</p> 106<a name="index-ifeq-directive"></a> 107</dd> 108<dt><code>.ifeq <var>absolute expression</var></code></dt> 109<dd><p>Assembles the following section of code if the argument is zero. 110</p> 111<a name="index-ifeqs-directive"></a> 112</dd> 113<dt><code>.ifeqs <var>string1</var>,<var>string2</var></code></dt> 114<dd><p>Another form of <code>.ifc</code>. The strings must be quoted using double quotes. 115</p> 116<a name="index-ifge-directive"></a> 117</dd> 118<dt><code>.ifge <var>absolute expression</var></code></dt> 119<dd><p>Assembles the following section of code if the argument is greater than or 120equal to zero. 121</p> 122<a name="index-ifgt-directive"></a> 123</dd> 124<dt><code>.ifgt <var>absolute expression</var></code></dt> 125<dd><p>Assembles the following section of code if the argument is greater than zero. 126</p> 127<a name="index-ifle-directive"></a> 128</dd> 129<dt><code>.ifle <var>absolute expression</var></code></dt> 130<dd><p>Assembles the following section of code if the argument is less than or equal 131to zero. 132</p> 133<a name="index-iflt-directive"></a> 134</dd> 135<dt><code>.iflt <var>absolute expression</var></code></dt> 136<dd><p>Assembles the following section of code if the argument is less than zero. 137</p> 138<a name="index-ifnb-directive"></a> 139</dd> 140<dt><code>.ifnb <var>text</var></code></dt> 141<dd><p>Like <code>.ifb</code>, but the sense of the test is reversed: this assembles the 142following section of code if the operand is non-blank (non-empty). 143</p> 144<a name="index-ifnc-directive"></a> 145</dd> 146<dt><code>.ifnc <var>string1</var>,<var>string2</var>.</code></dt> 147<dd><p>Like <code>.ifc</code>, but the sense of the test is reversed: this assembles the 148following section of code if the two strings are not the same. 149</p> 150<a name="index-ifndef-directive"></a> 151<a name="index-ifnotdef-directive"></a> 152</dd> 153<dt><code>.ifndef <var>symbol</var></code></dt> 154<dt><code>.ifnotdef <var>symbol</var></code></dt> 155<dd><p>Assembles the following section of code if the specified <var>symbol</var> 156has not been defined. Both spelling variants are equivalent. Note a symbol 157which has been referenced but not yet defined is considered to be undefined. 158</p> 159<a name="index-ifne-directive"></a> 160</dd> 161<dt><code>.ifne <var>absolute expression</var></code></dt> 162<dd><p>Assembles the following section of code if the argument is not equal to zero 163(in other words, this is equivalent to <code>.if</code>). 164</p> 165<a name="index-ifnes-directive"></a> 166</dd> 167<dt><code>.ifnes <var>string1</var>,<var>string2</var></code></dt> 168<dd><p>Like <code>.ifeqs</code>, but the sense of the test is reversed: this assembles the 169following section of code if the two strings are not the same. 170</p></dd> 171</dl> 172 173<hr> 174<div class="header"> 175<p> 176Next: <a href="Incbin.html#Incbin" accesskey="n" rel="next">Incbin</a>, Previous: <a href="Ident.html#Ident" accesskey="p" rel="previous">Ident</a>, Up: <a href="Pseudo-Ops.html#Pseudo-Ops" accesskey="u" rel="up">Pseudo Ops</a> [<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> 177</div> 178 179 180 181</body> 182</html> 183