WHILE Directive 

The WHILE directive can also be used to repeat a block of statements. Its syntax is

     WHILE expression
       statments
     ENDM

The statments in the macro body are repeated until the expression evaluates to false (zero). The expression is evaluated before each iteration of the macro body.

Example: Write a macro to initialize a block of memory to the first N integers.
   BLOCK2  MACRO  N  
             K=1
             WHILE K LE N
               DW K
               K=K+1
             ENDM
           ENDM
 

The macro invocation shown below

     C  LABEL  WORD
        BLOCK2 5
will expand as follows
     C  DW    1
        DW    2
        DW    3
        DW    4
        DW    5