A term can be any of the following:
o A number.
o A numeric symbol.
o A label.
o The current location counter.
o Any of the previously noted items preceded by a unary
operator.
MACRO-64 evaluates terms as quadword (8-byte) values. The current
location counter (.) has the value of the location counter at
the start of the current operand.
MACRO-64 considers unary operators part of a term and, thus,
performs the action indicated by a unary operator before it
performs the action indicated by a binary operator.
Expressions are combinations of terms joined by binary operators
and evaluated as quadword (8-byte) values. MACRO-64 evaluates
expressions from left to right with no operator precedence rules.
However, you can use angle brackets (<>) to change the order
of evaluation. Any part of an expression that is enclosed in
angle brackets is first evaluated to a single value, which is
then used in evaluating the complete expression. For example, the
expressions A*B+C and A*<B+C> are different. In the first case, A
and B are multiplied and then C is added to the product. In the
second case, B and C are added and the sum is multiplied by A.
You can also use angle brackets to apply a unary operator to an
entire expression, such as -<A+B>.
Expressions fall into four categories: relocatable, absolute,
external (global), and complex. You can determine the type of
expression by the following rules:
o An expression is relocatable if its value is fixed relative
to the start of the psect in which it appears. The current
location counter is relocatable in a relocatable psect.
o An expression is absolute if its value is an assembly-
time constant. An expression whose terms are all numbers
is absolute. An expression that consists of a relocatable
term minus another relocatable term from the same psect is
absolute, because such an expression reduces to an assembly-
time constant.
o An expression is external if it is not complex, and it
contains one or more symbols that are not defined in the
current module.
o An expression is complex if it contains a relocatable or
external term or subexpression that is operated upon by an
operator other than the plus sign (+) or the minus sign
(-). An expression is also complex if it contains more than
one term or subexpression that is relocatable or external.
An exception to this rule is the difference between two
relocatable subexpressions or terms where both relocatable
values occur in the same psect. In this case, the expression
is absolute.
Complex expressions are constrained to use the following form:
FORMAT
term operator term
term
Term is a relocatable or external subexpression.
operator
Operator is any of the MACRO-64 operators.
Neither term can itself be a complex subexpression. If you
specify a complex expression that does not match the correct
form, the assembler issues a diagnostic error message indicating
that the expression is too complex. Note also that the assembler
does not attempt to reorder expressions to make your expressions
match the correct form. For example, the following expression is
too complex:
.external E1, E2
.quad E1+5+E2+6 ; too complex
Because the assembler has no precedence rules, it attempts to
evaluate the previous expression as <<<E1+5>+E2>+6>. Since
<<E1+5>+E2> is itself a complex term, <<<E1+5>+E2>+6> does not
match the previous form and is too complex. However, you can
regroup the expression using angle brackets (<>) to match the
required form as follows:
.external E1, E2
.quad <E1+5>+<E2+6> ; legal complex expression
In this case, both <E1+5> and <E2+6> are simple, external terms.
Since none of the terms are complex, the expression matches the
correct form and the assembler accepts the complex expression.
You can use any type of expression in most MACRO-64 statements,
but restrictions are placed on expressions used in the following
contexts:
o .BASE directive.
o .BLKx storage allocation directives.
o .IF conditional assembly block directives.
o .REPEAT repeat block directives.
o Direct assignment statements.
o Lexical string operator arguments.
Expressions used in these contexts can contain only symbols or
labels that have been previously defined in the current module.
The .BASE directive accepts expressions that contain external
symbols previously declared with the .EXTERNAL directive. The
other contexts previously described cannot accept expressions
that contain external symbols. Symbols defined later in the
current module cannot be used in any of these contexts.
Expressions in the .IF conditional directives, .REPEAT
conditional directives, and lexical string operator arguments
are relocatable. However, expressions in the .BLKx directives
must be absolute.
Expressions cannot contain floating-point numbers. The floating-
point data-storage directives accept constant values. They do not
accept floating-point expressions.
The following example shows the use of expressions:
A = 2*100 ; 2*100 is an absolute expression
.BLKB A+50 ; A+50 is an absolute expression and
; contains no undefined symbols
LAB: .BLKW A ; LAB is relocatable
HALF = LAB+<A/2> ; LAB+<A/2> is a relocatable
; expression and contains no
; undefined symbols
LAB2: .BLKB LAB2-LAB ; LAB2-LAB is an absolute expression
; and contains no undefined symbols