4.2.1.1 Local Labels
Local labels are used when a temporary scope for a label is needed.
To define a local label, use a numerical symbol as the label name, for example
N:
, (where N
is a
number).
To refer to the most recent previous definition of the label
N:
, use Nb
. The
b
stands for “backwards.” To refer to the next definition of a local label,
write Nf
(“forwards”).
There is no restriction on how you use and reuse labels. You can
repeatedly define the same local label (using the same number
N
), although you must either refer to the most recently
defined local label of that number (for a backwards reference) or the next definition of a
specific local label for a forward reference.
Also note that the first 10 local labels (0:
. . .
9:
) are implemented more efficiently manner than the others.
Here is an example of local labels being defined and jumps to use the
branch instruction, b
:
1:
b 1f
2:
b 1b
1:
b 2f
2:
b 1b
Which is the equivalent code to the following, which used ordinary lables:
label_1:
b label_3
label_2:
b label_1
label_3:
b label_4
label_4:
b label_3
Local label names are only a notational device. They are immediately transformed into more conventional symbol names before the assembler uses them. These conventional symbol names are stored in the symbol table and appear in error messages and optionally emitted to the object file.