[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An expression specifies an address or numeric value. Whitespace may precede and/or follow an expression.
The result of an expression must be an absolute number, or else an offset into
a particular section. If an expression is not absolute, and there is not
enough information when as
sees the expression to know its
section, a second pass over the source program might be necessary to interpret
the expression--but the second pass is currently not implemented.
as
aborts with an error message in this situation.
6.1 Empty Expressions 6.2 Integer Expressions
An empty expression has no value: it is just whitespace or null.
Wherever an absolute expression is required, you may omit the
expression, and as
assumes a value of (absolute) 0. This
is compatible with other assemblers.
An integer expression is one or more arguments delimited by operators.
6.2.1 Arguments 6.2.2 Operators 6.2.3 Prefix Operator Prefix Operators 6.2.4 Infix Operators
Arguments are symbols, numbers or subexpressions. In other contexts arguments are sometimes called "arithmetic operands". In this manual, to avoid confusing them with the "instruction operands" of the machine language, we use the term "argument" to refer to parts of expressions only, reserving the word "operand" to refer only to machine instruction operands.
Symbols are evaluated to yield {section NNN} where section is one of text, data, bss, absolute, or undefined. NNN is a signed, 2's complement 32 bit integer.
Numbers are usually integers.
A number can be a flonum or bignum. In this case, you are warned
that only the low order 32 bits are used, and as
pretends
these 32 bits are an integer. You may write integer-manipulating
instructions that act on exotic constants, compatible with other
assemblers.
Subexpressions are a left parenthesis `(' followed by an integer expression, followed by a right parenthesis `)'; or a prefix operator followed by an argument.
Operators are arithmetic functions, like +
or %
. Prefix
operators are followed by an argument. Infix operators appear
between their arguments. Operators may be preceded and/or followed by
whitespace.
as
has the following prefix operators. They each take
one argument, which must be absolute.
-
~
Infix operators take two arguments, one on either side. Operators
have precedence, but operations with equal precedence are performed left
to right. Apart from +
or `-', both arguments must be
absolute, and the result is absolute.
*
/
%
<
<<
>
>>
|
Bitwise Inclusive Or.
&
^
!
+
-
==
<>
<
>
>=
<=
The comparison operators can be used as infix operators. A true results has a value of -1 whereas a false result has a value of 0. Note, these operators perform signed comparisons.
&&
||
These two logical operations can be used to combine the results of sub expressions. Note, unlike the comparison operators a true result returns a value of 1 but a false results does still return 0. Also note that the logical or operator has a slightly lower precedence than logical and.
In short, it's only meaningful to add or subtract the offsets in an address; you can only have a defined section in one of the two arguments.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |