Go to the first, previous, next, last section, table of contents.

Arithmetic expressions in GASP

There are two kinds of expressions, depending on their result: absolute expressions, which resolve to a constant (that is, they do not involve any values unknown to GASP), and relocatable expressions, which must reduce to the form

addsym+const-subsym

where addsym and subsym are assembly symbols of unknown value, and const is a constant.

Arithmetic for GASP expressions follows very similar rules to C. You can use parentheses to change precedence; otherwise, arithmetic primitives have decreasing precedence in the order of the following list.

  1. Single-argument + (identity), - (arithmetic opposite), or ~ (bitwise negation). The argument must be an absolute expression.
  2. * (multiplication) and / (division). Both arguments must be absolute expressions.
  3. + (addition) and - (subtraction). At least one argument must be absolute.
  4. & (bitwise and). Both arguments must be absolute.
  5. | (bitwise or) and ~ (bitwise exclusive or; ^ in C). Both arguments must be absolute.


Go to the first, previous, next, last section, table of contents.