SPRU514Z July 2001 – October 2023 SM320F28335-EP
You can define global constants in assembly language by using the .set directive in combination with either the .def or .global directive, or you can define them in a linker command file using a linker assignment statement. These constants are accessible from C/C++ only with the use of special operators.
For variables defined in C/C++ or assembly language, the symbol table contains the address of the value contained by the variable. When you access an assembly variable by name from C/C++, the compiler gets the value using the address in the symbol table.
For assembly constants, however, the symbol table contains the actual value of the constant. The compiler cannot tell which items in the symbol table are addresses and which are values. If you access an assembly (or linker) constant by name, the compiler tries to use the value in the symbol table as an address to fetch a value. To prevent this behavior, you must use the & (address of) operator to get the value (_symval). In other words, if x is an assembly language constant, its value in C/C++ is &x. See the section on "Using Linker Symbols in C/C++ Applications" in the TMS320C28x Assembly Language Tools User's Guide for examples that use _symval.
For more about symbols and the symbol table, refer to the section on "Symbols" in the TMS320C28x Assembly Language Tools User's Guide.
You can use casts and #defines to ease the use of these symbols in your program, as in the following examples.