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 (*).

Expression Operators 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
<= less than or equal to
>= greater than or equal to
>= greater than or equal to
< less than
@ at
Unary + unary plus
- unary minus
~ unary bitwise complement
Alternate <> not equal to
% modulo
| logical OR
|| logical XOR

Operator precedence is:

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