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