Section 3: Assembler
143
TI
-
89 / TI
-
92 Plus Sierra C Assembler Reference Manual
Not for Distribution
Beta Version February 2, 2001
3.3.5.2. Labels
A label is a symbol that is used to represent an address in a section. Labels are
defined as shown in the description of the various statement syntaxes (see
section 3.3.2 Assembler Statements). A label is either absolute or relocatable;
this property is inherited from the section in which it is defined.
When a label is defined, it is assigned the value of the current section’s location
counter (i.e., the current object code address). In the following code fragment,
the symbol loop is assigned the address of the move instruction:
jsr
init
loop:
move.l
(a0)+,(a1)+
cmpa.l
#end,a0
bne
loop
This value is either absolute or relocatable, depending on the active section. As
discussed earlier, relocatable sections are bound to absolute addresses during
linkage. At this time, relocatable labels become absolute.
By default, the scope of a label is static (i.e., local to the file in which it is
defined). This scope can be extended to other files by defining the label to be
external (see .xdef / XDEF directive). When using asm68k, it is also possible to
limit the scope of a label to a particular subset of a source file. A local label is
defined by prefixing its name with a period ( . ) (with the OPT LLBL directive in
effect). Ordinary (i.e., non-local) labels delineate unique local label scopes, i.e.,
each time an ordinary label is defined, a new local label scope is created. This
means that the same label name can be used in different local label scopes
without conflict. In addition, labels can be defined to be local to macro
invocations (see section 3.8.1.4 Local Labels).
3.3.5.3. Symbol
Assignment
Symbols can be assigned arbitrary values by direct assignment. When using
asm68, assignment is performed with the = and == operators. The right-hand
side of the assignment is an absolute or simple relocatable expression (see
section 3.3.7.3 Expression Evaluation) that contains no forward, external, or
undefined references. The value of this expression is assigned to the symbol on
the left-hand side of the assignment.
Using the = operator prohibits the defined symbol from being assigned a new
value, while the == operator permits future assignments. Attempting to assign a
value to a symbol whose value has been set with the = operator results in an
error.