4.9.53 Set Directive
SET directive is equivalent to EQU
(Equ Directive), except that
it allows a symbol to be re-defined in the same module without error. For
example:thomas SET 0h
; code using first value
thomas SET 44h
;code using second valuewill equate the symbol thomas to the
value 0, then later in the program, equate the same symbol to the different value 0x44.This directive performs a similar function to that of the preprocessor’s
#define directive (see Preprocessor Directives), which is often
preferred in assembly programs to represent values with symbols.
Note that this directive does not create variables. It does not reserve
any memory for the symbol created. Use the DS directive to reserve data
memory associated with a label (see Ds Directive).
When working with multiple assembly modules, it's possible to have multiple local symbols
with the same name. However, only SET symbols marked as globally
accessible (see Global Directive)
will be visible during debugging. The IDE will display the value of globally defined
symbols, but the value of local symbols will be used by the code within the modules where
they are defined. To avoid confusion, it's advisable not to define symbols with the same
name in different modules.
GLOBAL mode
mode SET 2the mode symbol will be watchable in IDEs, with an
indicated "address" of 2.Since SET directives do not contribute to the output, they are processed
separately to other instructions and directives. Thus, the program location counter cannot
be used in SET operand expressions.
