IRP Directive 

The IRP (iteration repeat) directive provides a means of supplying a variable parameter to each iteration of a repeat block. It syntax is

     IRP parameter, < argument1 [, argument2, ...] >
       statments
     ENDM
The arguments are given as a list separated by commas. Note that the angle brackets are part of the syntax and are required.

During the first iteration, argument1 is assigned to the parameter for use in the block of repeat statements; during the second iteration, argument2 is assigned, and so on. Therefore, the argument list specifies both the number of iterations and the actual values to be used in each iteration.

Example: Write a macro to save and restore an arbitrary number of registers.
 SAVE_REGS  MACRO  REGS       RESTORE_REGS  MACRO REGS
              IRP D, <REGS>                   IRP D, <REGS> 
                  PUSH D                          POP D
              ENDM                            ENDM
            ENDM                            ENDM
 

To save registers AX, BX, CX, DX, we can write

     SAVE_REGS < AX, BX, CX, DX >
which will be expanded into
     PUSH AX
     PUSH BX
     PUSH CX
     PUSH DX
To restore these registers, write
     RESTORE_REGS < DX, CX, BX, AX >