SPNU118Z September 1995 – March 2023 66AK2E05 , 66AK2H06 , 66AK2H12 , 66AK2H14 , AM1705 , AM1707 , AM1802 , AM1806 , AM1808 , AM1810 , AM5K2E04 , OMAP-L132 , OMAP-L137 , OMAP-L138 , SM470R1B1M-HT , TMS470R1A288 , TMS470R1A384 , TMS470R1A64 , TMS470R1B1M , TMS470R1B512 , TMS470R1B768
Define Assembly-Time Constant
symbol .set value
symbol .equ value
The .setand .equ directives equate a constant value to a .set/.equ 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 .set and .equ directives are identical and can be used interchangeably.
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 (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 and .equ.
1 *****************************************************
2 ** Equate symbol AUX_R1 to register AR1 and use **
3 ** it instead of the register. **
4 **********************************************
5 00000001 AUX_R1 .set R1
6 00000000 E3A01056 MOV AUX_R1, #56h
7
8 *****************************************************
9 ** Set symbol index to an integer expression. **
10 ** and use it as an immediate operand. **
11 *****************************************************
12 00000035 INDEX .equ 100/2 +3
13 00000004 E2810035 ADD R0, AUX_R1, #INDEX
14
15 *****************************************************
16 ** Set symbol SYMTAB to a relocatable expression. **
17 ** and use it as a relocatable operand. **
18 *****************************************************
19 00000008 0000000A LABEL .word 10
20 00000009' SYMTAB .set LABEL + 1
21
22 *****************************************************
23 ** Set symbol NSYMS equal to the symbol INDEX **
24 ** INDEX and use it as you would INDEX. **
25 *****************************************************
26 00000035 NSYMS .set INDEX
27 0000000c 00000035 .word NSYMS