SPNU118Z September 1995 – March 2023 66AK2E05 , 66AK2H06 , 66AK2H12 , 66AK2H14 , AM1705 , AM1707 , AM1802 , AM1806 , AM1808 , AM1810 , AM5K2E04 , OMAP-L132 , OMAP-L137 , OMAP-L138 , SM470R1B1M-HT , TMS470R1A288 , TMS470R1A384 , TMS470R1A64 , TMS470R1B1M , TMS470R1B512 , TMS470R1B768
All labels in an assembly language program must be unique. This includes labels in macros. If a macro is expanded more than once, its labels are defined more than once. Defining a label more than once is illegal. The macro language provides a method of defining labels in macros so that the labels are unique. Simply follow each label with a question mark, and the assembler replaces the question mark with a period followed by a unique number. When the macro is expanded, you do not see the unique number in the listing file. Your label appears with the question mark as it did in the macro definition. You cannot declare this label as global. See Section 4.8.3 for more about labels.
The syntax for a unique label is:
label ? |
Unique Labels in a Macro shows unique label generation in a macro. The maximum label length is shortened to allow for the unique suffix. For example, if the macro is expanded fewer than 10 times, the maximum label length is 126 characters. If the macro is expanded from 10 to 99 times, the maximum label length is 125. The label with its unique suffix is shown in the cross-listing file. To obtain a cross-listing file, invoke the assembler with the --asm_cross_reference_listing option (see Section 4.14).
1 ; define macro to find minimum
2 MIN .macro dst, src1, src2
3 CMP src1, src2
4 BCC m1?
5 MOV dst, src1
6 B m2?
7
8 m1? MOV dst, src2
9 m2?
10 .endm
11
12 ; call macro
13 00000000 .state16
14 00000000 MIN r4, r1, r2
1 00000000 4291 CMP r1, r2
1 00000002 D301 BCC m1?
1 00000004 1C0C MOV r4, r1
1 00000006 E000 B m2?
1
1 00000008 1C14 m1? MOV r4, r2
1 0000000a m2?