Expression Evaluation
Expressions can be used in data definitions and in source code (e.g. as an array index). Expressions can be contained within pre-processor symbols. e.g.
Within source code, all expressions are considered to be integer expressions. In numerical fields of data definitions, expressions are either integer or floating-point, depending upon the type of the field. For example, the Scalar field of a parameter is integer unless a ‘*’ character is used to indicate that it is floating-point.
Integer expressions can contain the following operators:
In both C and ASM code, ordered by precedence:
| Operator | Description | Associativity |
|---|---|---|
| () | Parentheses (grouping) | left-to-right |
| + - ! ~ | Unary plus/minus Unary logical negation/bitwise complement | right-to-left |
| * / % | Multiplication/division/modulus | left-to-right |
| + - | Addition/subtraction | left-to-right |
| « » | Bitwise shift left, Bitwise shift right | left-to-right |
| < <= > >= | Relational less than/less than or equal to Relational greater than/greater than or equal to | left-to-right |
| == != | Relational is equal to/is not equal to | left-to-right |
| & | Bitwise AND | left-to-right |
| ^ | Bitwise exclusive OR | left-to-right |
| | | Bitwise inclusive OR | left-to-right |
| && | Logical AND | left-to-right |
| || | Logical OR | left-to-right |
In ASM code, the following symbols are predefined by default:
div \
sdiv \
mult *
and &
or |
xor ^
shr >>
shl <<
lt <
gt >
slt <
sgt >
le <=
ge >=
sle <=
sge >=
eq ==
ne !=Floating-point expressions may only contain arithmetic operators – they cannot contain bitwise operators or conditional operators.