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
PartsDescription
LAll local labels begin with ‘L’.
DigitIf 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-AThis unusual character is included so you do not accidentally invent a symbol of the same name. The character has ASCII value ‘ \001’.
Ordinal numberThis 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.
00000000 <print_string>:
   0:	10 02       	mov.w     w0, w1
   2:	00 00       	neop      

00000004 <L1^B1>:
   4:	08 20 01 b9 	cp.b      [w1], #0x0
   8:	0a 00 00 a6 	bra       Z, 0xc
   c:	08 60 01 83 	mov.b     [w1++], w0
  10:	02 00 00 de 	call      0x000000
  14:	0a 00 00 ae 	bra       0x18 <L91>

00000018 <L9^B1>:
  18:	01 72       	return    
  1a:	00 00       	neop