Macro Parameters/Substitution Symbols
5-13
Macro Language
Example 5–9. Using Subscripted Substitution Symbols to Find Substrings
substr
.macro
start,strg1,strg2,pos
.var
LEN1,LEN2,I,TMP
.if
$symlen(start) = 0
.eval
1,start
.endif
.eval
0,pos
.eval
1,i
.eval
$symlen(strg1),LEN1
.eval
$symlen(strg2),LEN2
.loop
.break
i = (LEN2 – LEN1 + 1)
.asg
”:strg2(i,LEN1):”,TMP
.if
$symcmp(strg1,TMP) = 0
.eval
i,pos
.break
.else
.eval
i + 1,i
.endif
.endloop
.endm
.asg
0,pos
.asg
”ar1 ar2 ar3 ar4”,regs
substr
1,”ar2”,regs,pos
.data
.word
pos
In Example 5–9, the subscripted substitution symbol is used to find a substring
strg1, beginning at position start in the string strg2. The position of the
substring strg1 is assigned to the substitution symbol pos.
5.3.7
Substitution Symbols as Local Variables in Macros
If you want to use substitution symbols as local variables within a macro, you
can use the .var directive to define up to 32 local macro substitution symbols
(including parameters) per macro. The .var directive creates temporary substi-
tution symbols with the initial value of the null string. These symbols are not
passed in as parameters, and after expansion they are lost.
.var
sym
1
[,sym
2
] ... [,sym
n
]
The .var directive is used in Example 5–8 and Example 5–9.
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: ......