6.1.9.44 Set Directive
The
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 value
will 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).
As there can be more than one local symbol in separate assembly modules with the same name,
only
SET
symbols that are marked as being globally accessible (See Global Directive) will be visible when
debugging. For example, in the following
code:GLOBAL mode
mode SET 2
the mode
symbol will be watchable in IDEs.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.