4.4 Numeric local labels

Numeric local labels are a type of label that you refer to by a number rather than by name. Unlike other labels, the same numeric local label can be used multiple times and the same number can be used for more than one numeric local label.

ARM syntax

A numeric local label is a number in the range 0-99, optionally followed by a scope name corresponding to a ROUT directive.
Numeric local labels follow the same syntax as all other labels.
Refer to numeric local labels using the following syntax:
%[F|B][A|T]n[routname]
Where:
  • F and B instruct the assembler to search forwards and backwards respectively. By default, the assembler searches backwards first, then forwards.
  • A and T instruct the assembler to search all macro levels or only the current macro level respectively. By default, the assembler searches all macros from the current level to the top level, but does not search lower level macros.
  • n is the number of the numeric local label in the range 0-99.
  • routname is an optional scope label corresponding to a ROUT directive. If routname is specified in either a label or a reference to a label, the assembler checks it against the name of the nearest preceding ROUT directive. If it does not match, the assembler generates an error message and the assembly fails.
For example, the following code implements an incrementing loop:
         MOV      r4,#1       ; r4=1
1                             ; Local label
         ADD      r4,r4,#1    ; Increment r4
         CMP      r4,#0x5     ; if r4 < 5...
         BLT      %b1         ; ...branch backwards to local label "1"
Here is the same example using a ROUT directive to restrict the scope of the local label:
routA    ROUT                 ; Start of "routA" scope
         MOV      r4,#1       ; r4=1
1routA                        ; Local label
         ADD      r4,r4,#1    ; Increment r4
         CMP      r4,#0x9     ; if r4 < 9...
         BLT      %b1routA    ; ...branch backwards to local label "1routA"
routB    ROUT                 ; Start of "routB" scope (and therefore end of "routA" scope)

GNU syntax

A numeric local label is a number in the range 0-99.
Numeric local labels follow the same syntax as all other labels.
Refer to numeric local labels using the following syntax:
n{f|b}
Where:
  • n is the number of the numeric local label in the range 0-99.
  • f and b instruct the assembler to search forwards and backwards respectively. There is no default. You must specify one of f or b.
For example, the following code implements an incrementing loop:
         MOV      r4,#1       // r4=1
1:                            // Local label
         ADD      r4,r4,#1    // Increment r4
         CMP      r4,#0x5     // if r4 < 5...
         BLT      1b          // ...branch backwards to local label "1"

Note

GNU syntax assembly code does not provide mechanisms for restricting the scope of local labels.
Related reference
4.3 Labels
Related information
GNU Binutils - Using as: Labels
GNU Binutils - Using as: Local labels
armasm User Guide: Labels
armasm User Guide: Numeric local labels
armasm User Guide: Syntax of numeric local labels
armasm User Guide: ROUT
Non-ConfidentialPDF file icon PDF versionARM DUI0742F
Copyright © 2014-2016 ARM. All rights reserved.