SPRU513Z August 2001 – October 2023 SM320F28335-EP
The following built-in substitution symbol functions enable you to make decisions on the basis of the string value of substitution symbols. These functions always return a value, and they can be used in expressions. Built-in substitution symbol functions are especially useful in conditional assembly expressions. Parameters of these functions are substitution symbols or character-string constants.
In the function definitions shown in Table 6-1, a and b are parameters that represent substitution symbols or character-string constants. The term string refers to the string value of the parameter. The symbol ch represents a character constant.
| Function | Return Value |
|---|---|
| $symlen (a) | Length of string a |
| $symcmp (a,b) | < 0 if a < b; 0 if a = b; > 0 if a > b |
| $firstch (a,ch) | Index of the first occurrence of character constant ch in string a |
| $lastch (a,ch) | Index of the last occurrence of character constant ch in string a |
| $isdefed (a) | 1 if string a is defined in the symbol table |
| 0 if string a is not defined in the symbol table | |
| $ismember (a,b) | Top member of list b is assigned to string a |
| 0 if b is a null string | |
| $iscons (a) | 1 if string a is a binary constant |
| 2 if string a is an octal constant | |
| 3 if string a is a hexadecimal constant | |
| 4 if string a is a character constant | |
| 5 if string a is a decimal constant | |
| $isname (a) | 1 if string a is a valid symbol name |
| 0 if string a is not a valid symbol name | |
| $isreg (a)(1) | 1 if string a is a valid predefined register name |
| 0 if string a is not a valid predefined register name |
The following example shows built-in substitution symbol functions.
1 global x, label
2 .asg label, ADDR ; ADDR = label
3 .if ($symcmp(ADDR,"label") = 0) ; evaluates to true
4 000000 8000! SUB ACC, @ADDR
5 .endif
6 .asg "x, y, z", list ; list = x, y, z
7 .if ($ismember(ADDR, list)) ; ADDR = x list = y,z
8 000001 8000! SUB ACC, @ADDR
9 .endif