FOR - Repeat assembly block

Syntax
  FOR <label>=<num> TO <num>
  
  
  ENDFOR
  
  
Synonym

None

Description

The FOR directive is an inline macro because it can generate multiple lines of assembly code from only one line of input code.

FOR takes an absolute expression and assembles the portion of code following it, the number of times represented by the expression. The FOR expression may be either a constant or a label previously defined using EQU or SET.

Note: The FOR directive is only available when the -Compat=b assembly option is used. Otherwise, the FOR directive is not supported.
Example

The following listing is an example of using FOR to create a 5-repetition loop.

Listing: Using the FOR directive in a loop

   FOR label=2 TO 6
     DC.B  label*7

   ENDFOR
Listing: Resulting output listing

 Abs. Rel.   Loc    Obj. code   Source line
 ---- ----   ------ ---------   -----------

    1    1                      FOR label=2 TO 6

    2    2                         DC.B  label*7

    3    3                      ENDFOR

    4    2   000000 0E               DC.B  label*7

    5    3                         ENDFOR

    6    2   000001 15               DC.B  label*7

    7    3                         ENDFOR

    8    2   000002 1C               DC.B  label*7

    9    3                         ENDFOR

   10    2   000003 23               DC.B  label*7

   11    3                         ENDFOR

   12    2   000004 2A               DC.B  label*7

   13    3                         ENDFOR
See also

ENDFOR - End of FOR block

-Compat: Compatibility modes assembler option