System information
3.3.6 Precedence of Operators
As a convenience to the programmer, ASM assumes that operators have a relative precedence of
application that allows the programmer to write expressions without nested levels of parentheses.
The resulting expression has assumed parentheses that are defined by the relative precedence.
The order of application of operators in unparenthesized expressions is listed below. Operators
listed first have highest precedence (they are applied first in an unparenthesized expression),
while operators listed last have lowest precedence. Operators listed on the same line have equal
precedence, and are applied from left to right as they are encountered in an expression.
* / MOD SHL SHR
- +
NOT
AND
OR XOR
Thus, the expressions shown to the left below are interpreted by the assembler as the fully
parenthesized expressions shown to the right.
a*b+c (a*b) + c
a+b*c a + (b*c)
a MOD b*c SHL I ((a MOD b) * c) SHL d
a OR b AND NOT c+d SHL e a OR (b AND (NOT (c + (d SHL e))))
Balanced, parenthesized subexpressions can always be used to override the assumed parentheses;
thus, the last expression above could be rewritten to force application of operators in a different
order, as shown:
( a OR b ) AND ( NOT c ) + d SHL e
This results in these assumed parentheses:
(a OR b ) AND ( (NOT c ) + ( d SHL e ) )
3.3 Forming the Operand CP/M Operating System Manual
3-9