Example 1. Macro Definition, Call, and Expansion

Macro definition: The following code defines a macro, add3, with four parameters:

1 * 2 3 * add3 4 * 5 * ADDRP = P1 + P2 + P3 6 7 add3 .macro P1, P2, P3, ADDRP 8 9 ADD ADDRP, P1, P2 10 ADD ADDRP, ADDRP, P3 11 .endm

Macro call: The following code calls the add3 macro with four arguments:

12 13 00000000 add3 R1, R2, R3, R0

Macro expansion: The following code shows the substitution of the macro definition for the macro call. The assembler substitutes R1, R2, R3, and R0 for the P1, P2, P3, and ADDRP parameters of add3.

1 1 00000000 E0810002 ADD R0, R1, R2 1 00000004 E0800003 ADD R0, R0, R3