| ||
Macro repetition specifies the repetition of a directive specified several times. For this purpose, the REPT directive is used, for example:
A EQU 10 REPT 100 DB A ENDM
This will generate 100 DB 10 directives. It is convenient to use the = operator with this directive, because it allows you to change the variable value multiple times, for example, using expressions like A = A + 5 .
The IRP directive has the following format:
IRP parameter, <list> ... ENDM
The block will be called the number of times corresponding to the number of parameters in the list. For example:
IRP REG, <EAX, EBX, ECX, EDX, ESI, EDI> PUSH REG ENDM
This will generate the following lines of code:
PUSH EAX PUSH EBX PUSH ECX PUSH EDX PUSH ESI PUSH EDI
The IRPC directive is as follows :
IRPC parameter, cstring Operators ENDM
For example:
IRPC CHAR, azklg CMP AL, '&CHAR&' JZ EndC ENDM EndC:
This fragment is the equivalent of the following sequence:
CMP AL, 'a' JZ EndC CMP AL, 'z' JZ EndC CMP AL, 'k' JZ EndC CMP AL, 'l' JZ EndC CMP AL, 'g' JZ EndC EndC:
The & character in the latter example is used to specify that the parameter of the repeat block must be computed even within the quotation marks. The & character stands for the macro operation that works within the repeat block, because repeat blocks are one of the types of macro commands.
| ||