Operations

Mathematical

Operations

Mathematical expressions can typically be used anywhere a number
is required in an addressing mode or directive parameter.

Note that care must be taken when using expressions because the
assembler, in many cases, does not check for overflows while
computing the value of an expression. For example, the expression
($FFFFFFFF + 1) / 2 will overflow during calculations and produce
a value of 0 when a value of $7FFFFFFF may be expected. All
calculations are performed using 32-bit binary arithemetic and
then converted to the correct size for code generation.

See Mathematical Values,050, for information about legal value
formats for mathematical expressions.

Order of Operation: The assembler uses standard order of
operation rules to evaluate mathematical expressions.
The following rules list the order of operations. For
operations within the same class (such as plus and minus),
the assembler evaluates the expression from left to right.

1. All expressions in parentheses are evaluated.
2. All negations and logical NOT operations are completed.
3. All logical AND and OR operations completed.
4. All multiply, division, and MOD operations are completed.
5. All addition and subtraction operations are completed.

List of Operations: The following is a list of legal operations and
the corresponding syntax:

Operation Syntax Resulting value
Negation - a two’s compliment
Logical NOT ! a one’s compliment
Logical AND a AND b bitwise AND
Logical OR a OR b bitwise OR
Multiply a * b integer multiplication
Division a / b integer division
a DIV b integer division
Modulus a MOD b remainder of division
Addition a + b integer addition
Subtraction a - b integer subtraction
.050052