SPRUI03E June 2015 – January 2023
Assign a Substitution Symbol
.asg "character string",substitution symbol
.define "character string",substitution symbol
.eval expression,substitution symbol
The .asg and .define directives assign character strings to substitution symbols. Substitution symbols are stored in the substitution symbol table. The .asg directive can be used in many of the same ways as the .set directive, but while .set assigns a constant value (which cannot be redefined) to a symbol, .asg assigns a character string (which can be redefined) to a substitution symbol.
The .define directive functions in the same manner as the .asg directive, except that .define disallows creation of a substitution symbol that has the same name as a register symbol or mnemonic. It does not create a new symbol name space in the assembler, rather it uses the existing substitution symbol name space. The .define directive is used to prevent corruption of the assembly environment when converting C/C++ headers. See Chapter 12 for more information about using C/C++ headers in assembly source.
The .eval directive performs arithmetic on substitution symbols, which are stored in the substitution symbol table. This directive evaluates the expression and assigns the string value of the result to the substitution symbol. The .eval directive is especially useful as a counter in .loop/.endloop blocks.
See the .unasg/.undefine topic for information on turning off a substitution symbol.
This example shows how .asg and .eval can be used.
1 .sslist ; show expanded substitution symbols
2
3 .asg *+B14(100), GLOB100
4 .asg *+B15(4), ARG0
5
6 00000000 003B22E4 LDW GLOB100,A0
# LDW *+B14(100),A0
7 00000004 00BC22E4 LDW ARG0,A1
# LDW *+B15(4),A1
8 00000008 00006000 NOP 4
9 0000000c 010401E0 ADD A0,A1,A2
10
11 .asg 0,x
12 .loop 5
13 .word 100*x
14 .eval x+1,x
15 .endloop
1 00000010 00000000 .word 100*x
# .word 100*0
1 .eval x+1,x
# .eval 0+1,x
1 00000014 00000064 .word 100*x
# .word 100*1
1 .eval x+1,x
# .eval 1+1,x
1 00000018 000000C8 .word 100*x
# .word 100*2
1 .eval x+1,x
# .eval 2+1,x
1 0000001c 0000012C .word 100*x
# .word 100*3
1 .eval x+1,x
# .eval 3+1,x
1 00000020 00000190 .word 100*x
# .word 100*4
1 .eval x+1,x
# .eval 4+1,x