28.2. Integer Expressions

An integer expression is one or more arguments delimited by operators.

28.2.1. Arguments

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 the assembler 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.

28.2.2. Operators

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 white-space.

28.2.3. Prefix Operator

The assembler has the following prefix operators. They each take one argument, which must be absolute.

-

Negation. Two's complement negation.

~

Complementation. Bitwise not.

28.2.4. Infix Operators

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.

  1. Highest Precedence

    *

    Multiplication.

    /

    Division. Truncation is the same as the C operator “/

    %

    Remainder.

    <, <<

    Shift Left. Same as the C operator “<<”.

    >, >>

    Shift Right. Same as the C operator “>>”.

  2. Intermediate precedence

    |

    Bitwise Inclusive Or.

    &

    Bitwise And.

    ^

    Bitwise Exclusive Or.

    !

    Bitwise Or Not.

  3. Lowest Precedence

    +

    Addition. If either argument is absolute, the result has the section of the other argument. You may not add together arguments from different sections.

    -

    Subtraction. If the right argument is absolute, the result has the section of the left argument. If both arguments are in the same section, the result is absolute. You may not subtract arguments from different sections.

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.