Define Assembly-Time Constant
.set/.equ
4-79
Assembler Directives
Syntax
symbol .set value
symbol .equ value
Description
The .set and .equ directives equate a constant value to a symbol. The symbol
can then be used in place of a value in assembly source. This allows you to
equate meaningful names with constants and other values.
-
The
symbol is a label that must appear in the label field.
-
The
value must be a well-defined expression; that is, all symbols in the ex-
pression must be previously defined in the current source module.
Undefined external symbols and symbols that are defined later in the module
cannot be used in the expression. If the expression is relocatable, the symbol
to which it is assigned is also relocatable.
The value of the expression appears in the object field of the listing. This value
is not part of the actual object code and is not written to the output file.
Symbols defined with .set or .equ can be made externally visible with the .def
or .global directive. In this way, you can define global absolute constants.
Example
This example shows how symbols can be assigned with .set and .equ.
1 **********************************************
2 ** Equate symbol AUX_R1 to register AR1 **
3 ** and use it instead of the register. **
4 **********************************************
5 0011 AUX_R1 .set AR1
6 000000 7711 STM #56h, AUX_R1
000001 0056
7
8 **********************************************
9 ** Set symbol index to an integer expr. **
10 ** and use it as an immediate operand. **
11 **********************************************
12 0035 INDEX .equ 100/2 +3
13 000002 F000 ADD #INDEX, A
000003 0035
14
15 **********************************************
16 ** Set symbol SYMTAB to a relocatable expr. **
17 ** and use it as a relocatable operand. **
18 **********************************************
19 000004 000A LABEL .word 10
20 0005’ SYMTAB .set LABEL + 1
21
22 **********************************************
23 ** Set symbol NSYMS equal to the symbol **
24 ** INDEX and use it as you would INDEX. **
25 **********************************************
26 0035 NSYMS .set INDEX
27 000005 0035 .word NSYMS
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: ......