## ALP Programming Guide and Reference

[prev][next][parent][TOC]

### FOR/IRP (Iterative Macro Expansion Using List of Arguments)

The FOR directive, used in combination with the ENDM directive, designates a block of statements to be repeated, once for each argument in the list enclosed by angle brackets. Each repetition substitutes the next item in the <Argument-List> entry for every occurrence of Parameter in the block.

Syntax

    FOR   Parameter ,   < Argument - List >
        .
        .
        .
    ENDM

Remarks

The obsolete spelling for the FOR directive is IRP.

You must enclose the <Argument-List> entry in angle brackets. It has the following format:

    < [ Argument   [ ,   Argument   . . . ] ] >

If an empty (<>) Argument is found in <Argument-List>, the Parameter name is replaced by a null value. If the argument list is empty, the FOR directive is ignored and no statements are copied. The assembler processes the block once for each Argument in the <Argument-List>, replacing each occurrence of Parameter in the macro body with the current Argument value.

The FOR/IRP-ENDM block does not have to be within a macro definition.

Example

In this example, the assembler produces the code DB 1 through DB 10.

    FOR     X ,   < 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 >
    DB      X
    ENDM

In the next example:

    FOR      ARGUMENT , < " first   line " , 13 , 10 ,
    " second   line " , 13 , 10 >
    DB      ARGUMENT
    ENDM

The assembler produces the code:

    DB     " first   line "
    DB     13
    DB     10
    DB     " second   line "
    DB     13
    DB     10