SPRUI03E June 2015 – January 2023
Following are examples of expressions that use relocatable and absolute symbols. These examples use four symbols that are defined in the same section:
.global extern_1 ; Defined in an external module
intern_1: .word '"D' ; Relocatable, defined in
; current module
intern_2 ; Relocatable, defined in
; current module
intern_3 ; Relocatable, defined in
; current module
The internal values must be forrmed by absolute constant expressions. The following examples are illegal because variables are used where constants are required.
.word extern_1 * intern_2 - 13 ; Illegal
MVKL (intern_1 - extern_1),A1 ; Illegal
The first statement in the following example is valid; the statements that follow it are illegal
B (extern_1 - 10) ; Legal
B (10-extern_1) ; Can't negate reloc. symbol
LDW *+B14 (-(intern_1)), A1 ; Can't negate reloc. symbol
LDW *+B14 (extern_1/10), A1 ; / not an additive operator
B (intern_1 + extern_1) ; Multiple relocatables
The first statement below is legal; although intern_1 and intern_2 are relocatable, their difference is absolute because they are in the same section. Subtracting one relocatable symbol from another reduces the expression to relocatable symbol + absolute value. The second statement is illegal because the sum of two relocatable symbols is not an absolute value.
B (intern_1 - intern_2 + extern_3) ; Legal
B (intern_1 + intern_2 + extern_3) ; Illegal
A relocatable symbol's placement in the expression is important to expression evaluation. Although the statement below is similar to the first statement in the previous example, it is illegal because of left-to-right operator precedence; the assembler attempts to add intern_1 to extern_3.
B (intern_1 + extern_3 - intern_2) ; Illegal