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