144
Section 3: Assembler
TI
-
89 / TI
-
92 Plus Sierra C Assembler Reference Manual
Not for Distribution
Beta Version February 2, 2001
When using asm68k, the EQU and SET directives perform the same function as
the = and == operators, respectively (see section 3.7 Asm68k Assembler
Directives). As with labels, the default scope of symbols defined via assignment
is static (i.e., local to the file in which they are defined). The .xdef / XDEF
directive can be used to define a symbol to be external.
3.3.5.4.
Comm and Lcomm Symbols
The final way that symbols can be defined is with the .comm / COMM and
.lcomm / LCOMM directives. These directives are used to define symbols that
are referred to as comm and lcomm symbols, respectively. Each such symbol is
associated with a block of uninitialized data in the .bss section. The primary
difference between the two types of symbols is their scope: comm symbols are
external and lcomm symbols are static (i.e., local to the file in which they are
defined). For syntax, descriptions, and examples of these directives, refer to
sections 3.6 Asm68 Assembler Directives and 3.7 Asm68k Assembler
Directives.
The names for these two types of symbols come from the expressions
common
area and common block, which are used in languages such as FORTRAN.
These directives were originally used for compatibility with these languages;
therefore, they allow symbols to be redefined, provided the size and alignment
information are identical. If the
-C
linker command flag is specified at link time,
definitions of the same symbol can appear in other source files as well. These
directives are now typically used for allocating space for uninitialized data. For
historical reasons, the names have remained.
Since comm symbols can be defined in multiple source files, they cannot be
allocated by the assembler as lcomm symbols are. They are instead allocated
during linkage after all common definitions have been resolved.
3.3.5.5. Undefined
Symbols
If a symbol is referenced in a source file, but is not defined in that file (by label,
assignment, etc.) and has no external declaration, it is considered to be
undefined. When using asm68, any undefined symbols are assumed to be
external. When using asm68k, an error is generated for each undefined symbol
that is found. These behaviors can be reversed using the
-E
command line flag.
Furthermore, if the .opt (not OPT) directive is used in a file assembled by
asm68k, all undefined symbols are assumed to be external. The behavior switch
based on the detection of the .opt directive is needed to allow compiler
generated assembly code to be assembled by asm68k.
For both assemblers, undefined symbols are defined to be external in the output
object file and are shown as undefined in the listing file. The only difference in
behavior is whether or not an error message is generated.