You can define a symbolic name for a constant using the EQU, SET and DEFINE directives. You can also remove the definition of a symbol with the UNDEF directive and test if a symbol is defined using the DEFINED operator. The DEFINE and UNDEF directives may be prefixed with a # character which can be in the first column to emulate simple C pre-processor statements. The SFRB and SFRW directives may start in the first column and are typically used to access memory mapped peripheral registers.

##### Syntax

symbol EQU expression
symbol = expression
symbol SET expression
DEFINE symbol [expression]
UNDEF symbol
SFRB symbol = addressExpression
SFRW symbol = addressExpression

The assembler evaluates the expression and assigns that value to the symbol. For the EQU directive the expression need not be constant or even known at assembly time; it can be any value and may include complex operations involving external symbols. For the SET and DEFINE directive the expression must evaluate to an assemble time constant. The SET directive allows redefinition of an existing symbol, the EQU and DEFINE directives will produce an error if a symbol is redefined. The = operator is equivalent to the SET directive. The DEFINE directive need not be supplied an expression and the assembler will generate a default value for the symbol.

##### Example

    CR EQU 13

This defines the symbol CR to be a symbolic name for the value 13. Now you can use the symbol CR in expressions rather than the constant.

##### Example

    ADDRHI EQU (ADDR<<8) & 0FFH

This defines the symbol ADDRHI to be equivalent to the value of ADDR shifted right 8 bits and then bitwise-anded with 255. If ADDR is an external symbol defined in another module, then the expression involving ADDR cannot be resolved at assembly time as the value of ADDR isn’t known to the assembler. The value of ADDR is only known when linking and the linker will resolve any expression the assembler can't.

##### Example

    x = x-1

This redefines the symbol x to be the current value of x with 1 subtracted.

##### Example

    #if !defined(debug)
    #define debug
    #endif

This defines the symbol debug if it hasn't already been defined.