Using Labels in Macros
5-17
Macro Language
5.6
Using Labels in Macros
All labels in an assembly language program must be unique, including labels
in macros. If a macro is expanded more than once, its labels are defined more
than once, which
is illegal. The macro language provides a method of defining
labels in macros so that the labels are unique. Follow the label with a question
mark, and the assembler replaces the question mark with a unique number.
When the macro is expanded,
you will 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.
The maximum label length is shortened to allow for the unique suffix. 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.
The syntax for a unique label is:
label ?
Example 5–13 shows unique label generation in a macro.
Example 5–13. Unique Labels in a Macro
(a) Mnemonic example
1
; define macro
2
MIN
.macro AVAR, BVAR ; find minimum
3
4
LD
AVAR, A
5
SUB
#BVAR, A
6
BC
M1?, ALT
7
LD
#BVAR, A
8
B
M2?
9
M1?
LD
AVAR, A
10
M2?
11
.endm
12
13
; call macro
14 000000
MIN 50, 100
1
1
000000 1032
LD
50, A
1
000001 F010
SUB
#100, A
000002 0064
1
000003 F843
BC
M1?, ALT
000004 0008’
1
000005 E864
LD
#100, A
1
000006 F073
B
M2?
000007 0009’
1
000008 1032
M1?
LD
50, A
1
000009
M2?
Summary of Contents for TMS320C54x
Page 38: ......
Page 39: ......
Page 40: ......
Page 41: ......
Page 42: ......
Page 43: ......
Page 44: ......
Page 45: ......
Page 46: ......
Page 47: ......
Page 48: ......
Page 49: ......
Page 50: ......
Page 51: ......
Page 52: ......
Page 53: ......
Page 54: ......
Page 55: ......
Page 56: ......
Page 57: ......
Page 58: ......
Page 59: ......
Page 60: ......
Page 61: ......
Page 62: ......
Page 276: ......
Page 277: ......
Page 278: ......
Page 279: ......
Page 280: ......
Page 281: ......
Page 282: ......
Page 283: ......
Page 284: ......
Page 285: ......
Page 286: ......
Page 287: ......
Page 288: ......
Page 289: ......
Page 290: ......
Page 291: ......
Page 292: ......
Page 293: ......
Page 294: ......
Page 295: ......
Page 296: ......
Page 297: ......
Page 298: ......
Page 299: ......
Page 300: ......
Page 301: ......
Page 302: ......