Equates

An equate is a symbol that represents any value. To create an equate, use the .equ or .set directive.

The first character of an equate must be a:

Subsequent characters can be from the preceding list or a:

The assembler allows forward equates. This means that a reference to an equate can be in a file before the equate's definition. When an assembler encounters such a symbol whose value is not known, the assembler retains the expression and marks it as unresolved. After the assembler reads the entire file, it reevaluates any unresolved expressions. If necessary, the assembler repeatedly reevaluates expressions until it resolves them all or cannot resolve them any further. If the assembler cannot resolve an expression, it issues an error message.

Note: The assembler must be able to resolve immediately any expression whose value affects the location counter. If the assembler can make a reasonable assumption about the location counter, it allows the expression.

The code of Valid Forward Equate shows a valid forward equate.

Listing: Valid Forward Equate

        .data
        .long  alloc_size

alloc_size      .set   rec_size + 4

; a valid forward equate on next line

rec_size        .set   table_start-table_end

        .text

;...

table_start:

; ...

table_end:

However, the code of Invalid Forward Equate is not valid. The assembler cannot immediately resolve the expression in the .space directive, so the effect on the location counter is unknown.

Listing: Invalid Forward Equate

;invalid forward equate on next line
rec_size   .set   table_start-table_end

           .space rec_size

           .text; ...

table_start:

; ...

table_end: