Substitution Symbols

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 block2, stack-pointer ; 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:

myadd .macro src, dest ; addl macro definition ADD src, dest ; Add the value in register dest to the value in ; register src. .endm *myadd invocation myadd R4, R5 ; Calls the macro addl and substitutes R4 for src ; and R5 for dest. The macro adds the value of R4 ; and the value of R5.

See Section 6 for more information about macros.