SLAU131Y October 2004 – June 2021
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 14 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 sub. symbols
2 ; using .asg and .eval
3
4 .asg R12, LOCALSTACK
5 .asg &, AND
6
7 0000 503C ADD #280 AND 255, LOCALSTACK
# ADD #280 & 255, R12
0002 0018
8
9 .asg 0,x
10 .loop 5
11 .eval x+1, x
12 .word x
13 .endloop
1 .eval x+1, x
# .eval 0+1, x
1 0004 0001 .word x
# .word 1
1 .eval x+1, x
# .eval 1+1, x
1 0006 0002 .word x
# .word 2
1 .eval x+1, x
# .eval 2+1, x
1 0008 0003 .word x
# .word 3
1 .eval x+1, x
# .eval 3+1, x
1 000a 0004 .word x
# .word 4
1 .eval x+1, x
# .eval 4+1, x
1 000c 0005 .word x
# .word 5