SPRUI03E June 2015 – January 2023
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 5.9.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 5.14).
1 min .macro x,y,z
2
3 MV y,z
4 || CMPLT x,y,y
5 [y] B l?
6 NOP 5
7 MV x,z
8 l?
9 .endm
10
11
12 00000000 MIN A0,A1,A2
1
1 00000000 010401A1 MV A1,A2
1 00000004 00840AF8 || CMPLT A0,A1,A1
1 00000008 80000292 [A1] B l?
1 0000000c 00008000 NOP 5
1 00000010 010001A0 MV A0,A2
1 00000014 l?
LABEL VALUE DEFN REF
.TMS320C60 00000001 0
.tms320C60 00000001 0
l$1$ 00000014' 12 12