3-10-4 Assigning Names to Expressions

If an expression appears several times in a program, it is sometimes more convenient to give it a name and refer to it by the name.

The statement that assigns a name to an expression has the form

Expression name     EQU     Expression
where the expression name may be any valid identifier and the expression may have the format of any valid operand, be any expression that evaluates to a constant (the expression name is then a constant name), or be any valid mnemonic.

The MOV instruction in the sequence

INDXD_CHAR     EQU     CHAR_ARRAY[SI+10]
                .
                .
                .
               MOV     AL,INDXD_CHAR
                .
                .
                .
would be the same as
MOV     AL,CHAR_ARRAY[SI+10]

Figure 3-62 Examples of the EQU directive.

DirectiveDescription
CONSTANT   EQU     256
Assigns 256 to the name CONSTANT
DATA       EQU     HEIGHT+12
Assigns the direct operand HEIGHT+12 to the name DATA
FIELD      EQU     [BX].ETA[SI]
Assigns the structure referencing operand [BX].ETA[SI] to the name FIELD
ALPHA      EQU     7
BETA EQU ALPHA-2
ADDR EQU VAR+BETA
This combination would give 7 the name ALPHA, 7-2=5 the name BETA, and the direct operand VAR+BETA=VAR+5 the name ADDR

Table of Contents | Next page | Previous page

This is page 47.