SPRU513Z August 2001 – October 2023 SM320F28335-EP
Define Assembly-Time Constant
symbol .set value
The .setdirective equates a constant value to a .set 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.
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 can be made externally visible with the .def or .global directive (see the .global/.def/.ref topic). In this way, you can define global absolute constants.
This example shows how symbols can be assigned with .set .
1 **********************************************
2 ** Equate symbol AUX_R1 to register AR1 **
3 ** and use it instead of the register. **
4 **********************************************
5 0001 AUX_R1 .set AR1
6 000000 28C1 MOV *AUX_R1, #56h
000001 0056
7
8 **********************************************
9 ** Set symbol index to an integer expr. **
10 ** and use it as an immediate operand. **
11 **********************************************
12 0035 INDEX .set 100/2 +3
13 000002 0935 ADD ACC, #INDEX
14
15 **********************************************
16 ** Set symbol SYMTAB to a relocatable expr. **
17 ** and use it as a relocatable operand. **
18 **********************************************
19 000003 000A LABEL .word 10
20 0004' 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 000004 0035 .word NSYMS