You can use the ‘def’ directive to define or redefine a symbol:
name def value
This statement defines or redefines a symbol name to a value. A symbol name must start at the beginning of a line. A symbol value must not contain commas outside of string literals.
There are two possible scopes of a symbol: global and local. Defining a symbol outside of macros makes the symbol global. If a symbol is global one, a ‘def’ directive used for the symbol inside a macro redefines the global symbol to a new value.
Defining a symbol inside a macro makes the symbol local. Macro arguments are also local symbols. Local symbols are not visible outside of macros containing their definitions. If a symbol is local one, a ‘def’ directive used for the symbol inside a macro (containing the symbol definition) redefines the local symbol to a new value.
QSMM 1.19 introduces the ‘ldef’ directive for using inside a macro:
name ldef value
This statement defines or redefines a local symbol name to a value even if there exists a global symbol name.
Use the ‘def’ directive for defining or redefining global symbols and use the ‘ldef’ directive for defining or redefining local symbols.
The assembler preprocessor replaces with a symbol value every occurrence of a symbol name as a token in a symbol scope. To concatenate a symbol value with adjacent tokens, prepend and/or append the characters ‘##’ to a symbol name token.
For example, the source text
st def 01
choice
case a##st##_00, l##st##_00
case a##st##_01, l##st##_01
end choice
jmp l##st##_02
preprocesses to the text
choice
case a01_00, l01_00
case a01_01, l01_01
end choice
jmp l01_02
If a symbol value is not a (quoted) string literal, prepend the character ‘#’ to the symbol name token to convert the symbol value to a string literal. For example, the source text
id def 5 s##id: stt #id
preprocesses to the text
s5: stt "5"
The right-hand side of a symbol definition or redefinition can contain symbol names. After expanding the symbol names, the value of the symbol must reduce to either a string literal or other text without string literals, spaces, and commas.
The assembler preprocessor supports the predefined symbol ‘__UNIQUE__’ expanded to the next number from the sequence of natural numbers. You can use that symbol to generate unique location labels in macros.