SPNU118Z September 1995 – March 2023 66AK2E05 , 66AK2H06 , 66AK2H12 , 66AK2H14 , AM1705 , AM1707 , AM1802 , AM1806 , AM1808 , AM1810 , AM5K2E04 , OMAP-L132 , OMAP-L137 , OMAP-L138 , SM470R1B1M-HT , TMS470R1A288 , TMS470R1A384 , TMS470R1A64 , TMS470R1B1M , TMS470R1B512 , TMS470R1B768
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 Chapter 177 for more information about macros.