9.4 Defining Repeat Blocks with Loop Directives

A “repeat block” is an unnamed macro defined with a loop directive. It generates the statements inside the repeat block a specified number of times or until a given condition becomes true.

Several loop directives are available, providing different ways of specifying the number of iterations. Some loop directives also provide a way to specify arguments for each iteration. Although the number of iterations is usually specified in the directive, you can use the EXITM directive to exit from the loop early.

Repeat blocks can be used outside macros, but they frequently appear inside macro definitions to perform some repeated operation in the macro.

This section explains the following four loop directives: REPEAT, WHILE, FOR, and FORC. In previous versions of MASM, REPEAT was called REPT, FOR was called IRP, and FORC was called IRPC. MASM 6.0 still recognizes the old names.

NOTE:

The REPEAT and WHILE directives should not be confused with the .REPEAT and .WHILE directives (see Section 7.2.1, “Loop-Generating Directives”), which generate loop and jump instructions for run-time program control.