Symbols can be assigned a string value. This enables you to create aliases for character strings by equating them to symbolic names. Symbols that represent character strings are called substitution symbols. When the assembler encounters a substitution symbol, its string value is substituted for the symbol name. Unlike symbolic constants, substitution symbols can be redefined.
A string can be assigned to a substitution symbol anywhere within a program; for example:
.asg "SP", stack-pointer
; Assigns the string SP to the substitution symbol stack-pointer.
.asg "#0x20", block2
; Assigns the string #0x20 to the substitution symbol block2.
ADD stack-pointer, stack-pointer, block2
; Adds the value in SP to #0x20 and stores the result in SP.
When you are using macros, substitution symbols are important because macro parameters are actually substitution symbols that are assigned a macro argument. The following code shows how substitution symbols are used in macros:
addl .macro dest, src
; addl macro definition
ADDS dest, dest, src
; Add the value in register dest to the value in register src,
; and store the result in src.
BLCS reset_ctr
; Handle overflow.
.endm
*addl invocation
addl R4, R5
; Calls the macro addl and substitutes R4 for dest and R5 for src.
; The macro adds the value of R4 and the value of R5, stores the
; result in R4, and handles overflow.
See Section 6 for more information about macros.