as: TIC54X-Subsyms
1
1 9.45.5 String Substitution
1 --------------------------
1
1 A subset of allowable symbols (which we'll call subsyms) may be assigned
1 arbitrary string values. This is roughly equivalent to C preprocessor
1 #define macros. When 'as' encounters one of these symbols, the symbol
1 is replaced in the input stream by its string value. Subsym names
1 *must* begin with a letter.
1
11 Subsyms may be defined using the '.asg' and '.eval' directives (⇒
'.asg' TIC54X-Directives, ⇒'.eval' TIC54X-Directives.
1
1 Expansion is recursive until a previously encountered symbol is seen,
1 at which point substitution stops.
1
1 In this example, x is replaced with SYM2; SYM2 is replaced with SYM1,
1 and SYM1 is replaced with x. At this point, x has already been
1 encountered and the substitution stops.
1
1 .asg "x",SYM1
1 .asg "SYM1",SYM2
1 .asg "SYM2",x
1 add x,a ; final code assembled is "add x, a"
1
1 Macro parameters are converted to subsyms; a side effect of this is
1 the normal 'as' '\ARG' dereferencing syntax is unnecessary. Subsyms
1 defined within a macro will have global scope, unless the '.var'
11 directive is used to identify the subsym as a local macro variable ⇒
'.var' TIC54X-Directives.
1
1 Substitution may be forced in situations where replacement might be
1 ambiguous by placing colons on either side of the subsym. The following
1 code:
1
1 .eval "10",x
1 LAB:X: add #x, a
1
1 When assembled becomes:
1
1 LAB10 add #10, a
1
1 Smaller parts of the string assigned to a subsym may be accessed with
1 the following syntax:
1
1 ':SYMBOL(CHAR_INDEX):'
1 Evaluates to a single-character string, the character at
1 CHAR_INDEX.
1 ':SYMBOL(START,LENGTH):'
1 Evaluates to a substring of SYMBOL beginning at START with length
1 LENGTH.
1