SPNU118Z September 1995 – March 2023 66AK2E05 , 66AK2H06 , 66AK2H12 , 66AK2H14 , AM1705 , AM1707 , AM1802 , AM1806 , AM1808 , AM1810 , AM5K2E04 , OMAP-L132 , OMAP-L137 , OMAP-L138 , SM470R1B1M-HT , TMS470R1A288 , TMS470R1A384 , TMS470R1A64 , TMS470R1B1M , TMS470R1B512 , TMS470R1B768
This is an example of code that declares and uses a local label legally:
Label1: CMP r1, #0 ; Compare r1 to zero.
BCS $1 ; If carry is set, branch to $1;
ADDS r0, r0, #1 ; else increment to r0
MOVCS pc, lr ; and return.
$1: LDR r2, [r5], #4 ; Load indirect of r5 into r2
; with write back.
.newblock ; Undefine $1 so it can be used
; again.
ADDS r1, r1, r2 ; Add r2 to r1.
BPL $1 ; If the negative bit isn't set,
; branch to $1;
MVNS r1, r1 ; else negate r1.
$1: MOV pc, lr ; Return.
The following code uses a local label illegally:
BCS $1 ; If carry is set, branch to $1;
ADDS r0, r0, #1 ; else increment to r0
MOVCS pc, lr ; and return.
$1: LDR r2, [r5], #4 ; Load indirect of r5 into r2
; with write-back.
ADDS r1, r1, r2 ; Add r2 to r1.
BPL $1 ; If the negative bit isn't set,
; branch to $1;
MVNS r1, r1 ; else negate r1.
$1: MOV pc, lr ; Return.
The $1 label is not undefined before being reused by the second branch instruction. Therefore, $1 is redefined, which is illegal.