Expressions

The assembler uses 32-bit signed arithmetic to evaluates expressions; it does not check for arithmetic overflow.

As different processors use different operators, the assembler uses an expression syntax similar to that of the C language. Expressions use C operators and follow C rules for parentheses and associativity.

Note: To refer to the program counter in an expression, use a period (.), dollar sign ($), or asterisk (*).

The following table lists the expression operators that the assembler supports.

Table 1. Expression Operators
Category Operator Description
Binary + add
- subtract
* multiply
/ divide
% modulo
|| logical OR
&& logical AND
| bitwise OR
& bitwise AND
^ bitwise XOR
<< shift left
>> shift right (zeros are shifted into high order bits)
== equal to
!= not equal to
Binary <= less than or equal to
>= greater than or equal to
< less than
> greater than
Unary + unary plus
- unary minus
~ unary bitwise complement
Alternate <> not equal to

Operator precedence is:

  1. ( )
  2. @
  3. unary + - ~ !
  4. * / %
  5. binary + -
  6. << >>
  7. < <= > >=
  8. == !=
  9. &
  10. ^
  11. |
  12. &&
  13. ||

Gnu- or ADS-compatibility modes change some of these operator precedences.