.EQ     EQuate

Syntax:

label     .EQ    expression
label     =      expression

See also:

.SE  

Function:

The .EQ directive is used to assign a value other than the default current memory location value to a label. Alternatively the = symbol may be used instead of the .EQ directive.

Boundary Sync:

In Version 3 of the SB-Assembler this directive will perform a boundary sync.

Explanation:

The .EQ directive is used to assign a constant value to a label. Per default a new label will get the value of the current memory location. If you want the new label to get a different value than its default value you should use the .EQ directive. The = symbol is equivalent to the .EQ directive and has exactly the same effect.

A label that was assigned using the .EQ directive can be considered a constant value because its value can not be changed anymore in this assembly run.
Internally the label's value is always 32 bits long. The expression may not be preceded by the # / = and \ symbols to force the value to be only 8 bits in length.

Please note that the .EQ directive does not generate any code for the target system. It only assigns the expression's value to a label which helps us humans to cope better with meaningless numbers.

Forward referenced labels in the expression are not allowed. This means that all labels in the expression should be completely resolved.

The SB-Assembler will stop parsing the source line immediately after it has evaluated the expression. Everything following the expression is treated as a comment. This will allow you to let the expression be followed by a second expression to indicate that the label's value is the beginning of multiple addresses. It will have no effect on the value that is assigned to the label though and is only meant for documentary purposes.

Like all labels used with the SB-Assembler, labels declared with the .EQ directive may be redefined, as long as the new definition gives the label the same value as it already had. This is useful if labels are declared in libraries. Linking multiple libraries may cause some labels to be redefined. This is no problem as long as the definition results in the same value every time. For this redefinition it doesn't matter whether the label gets its value automatically or by using the .EQ directive.
The SB-Assembler will report an Extra definition error if a label is redefined with a different value than the first time.

It is even allowed to assign a value to Local labels using the .EQ directive. The SB-Assembler won't protest if you do. But remember that Local labels only "live" until the definition of the next Global label.

Legal Examples:

1234-       LABEL     .EQ    $1234        Assign a constant value to LABEL
000D-       CR        .EQ    $0D          Assign the Carriage Return to CR
0050-       POINTER   .EQ    $50,$51      Assign the value $50 to POINTER,
0000-       ;                              the rest is treated as comment
1236-       NEW       .EQ    LABEL+2      LABEL is already defined
ABCD-       ALT       =      $ABCD        = symbol is equivalent to .EQ
123456-     BIG       .EQ    $123456      Number larger than 16-bits
12345678-   VERYBIG   .EQ    $12345678    And even larger (up to 32 bits)

Illegal Examples:

            TEST      .EQ    FORWARD      Forward referenced!
            ERROR     .EQ    #$0D         # prefix not allowed here
                      .EQ    %1001        Label field is empty
            MISSING   .EQ                 ; The expression is missing