Monday, April 25, 2016

Description and Example of Named Constants


EQU (Equates)

To assign a name to a constant, we can use the EQU (equates) pseudo-op. THe syntax is 

name                            EQU                                     constant


For Example :   the statement

LF                         EQU                            0AH


assigns the name LF to 0Ah, the ASCII code of the line feed character. The name LF may now be used in place of 0Ah anywhere in the program. Thus, the assembler translates the instructions

MOV            DL, 0AH

and 

MOV DL,LF

into the same machine instruction

The symbol on the right of an EQU can also be a string 

Example :

PROMPT EQU  'TYPE YOUR NAME'

Then instead of

MSG       DB                    'TYPE YOUR NAME'

we could say

MSG    DB                    PROMPT

Note : no memory is allocated for EQU names.