4.5.2 Local Symbols

Local symbols are used when temporary scope for a label is needed. There are ten local symbol names, which can be reused throughout the program. They may be referred to by using the names ‘0’, ‘1’, ..., ‘9’. To define a local symbol, write a label of the form ‘N:’ (where N represents any digit 0-9). To refer to the most recent previous definition of that symbol, write ‘Nb’, using the same digit as when you defined the label. To refer to the next definition of a local label, write ‘Nf’. The ‘b’ stands for “backwards” and the ‘f’ stands for “forwards”. There is no restriction on how to use these labels; however, at any point in assembly, no more than 10 backward local labels and10 forward local labels may be referred to.

print_string:
mov    w0,w1
1:
cp0.b  [w1]
bra    z,9f
mov.b  [w1++],w0
call   print_char
bra    1b
9:
return

Local symbol names are only a notation device. They are immediately transformed into more conventional symbol names before the assembler uses them. The symbol names stored in the symbol table, appearing in error messages, and optionally emitted to the object file have the following parts:

Table 4-4. Symbol Parts
Parts Description
L All local labels begin with ‘L’.
Digit If the label is written ‘0:’, then the digit is ‘0’. If the label is written ‘1’, then the digit is ‘1’. And so on up through ‘9’.
CTRL-A This unusual character is included so you do not accidentally invent a symbol of the same name. The character has ASCII value ‘ \001’.
Ordinal number This is a serial number to keep the labels distinct. The first ‘0:’ gets the number ‘1’; the 15th ‘0:’ gets the number ‘15’; and so on. Likewise for the other labels ‘1:’ through ‘9:’. For instance, the first ‘1:’ is named L1C-A1, the 44th ‘3:’ is named L3C-A44.
00000100 <print_string>:
100:   80 00 78        mov.w     w0, w1
00000102 <L1·1>:
102:   11 04 e0        cp0.b     [w1]
104:   03 00 32        bra       Z, . + 0x8
106:   31 40 78        mov.b     [w1++], w0
108:   02 00 07        rcall     . + 0x6
10a:   fb ff 37        bra       . + 0xFFFFFFF8
0000010c <L9·1>:
10c:   00 00 06        return