3.5. Numbers and Expressions

Numbers can be expressed in binary, octal, decimal, or hexadecimal. Binary numbers may be prefixed with a "%" symbol or suffixed with a "b" or "B". Octal numbers may be prefixed with "@" or suffixed with "Q", "q", "O", or "o". Hexadecimal numbers may be prefixed with "$" or suffixed with "H". No prefix or suffix is required for decimal numbers but they can be prefixed with "&" if desired. Any constant which begins with a letter must be expressed with the correct prefix base identifier or be prefixed with a 0. Thus hexadecimal FF would have to be written either 0FFH or $FF. Numbers are not case sensitive.

A symbol may appear at any point where a number is acceptable. The special symbol "*" can be used to represent the starting address of the current source line within expressions.

The ASCII value of a character can be included by prefixing it with a single quote ('). The ASCII values of two characters can be included by prefixing the characters with a quote (").

LWASM supports the following basic binary operators: +, -, *, /, and %. These represent addition, subtraction, multiplication, division, and modulus. It also supports unary negation and unary 1's complement (- and ^ respectively). For completeness, a unary positive (+) is supported though it is a no-op.

Operator precedence follows the usual rules. multiplication, division, and modulus take precedence over addition and subtraction. Unary operators take precedence over binary operators. To force a specific order of evaluation, parentheses can be used in the usual manner.