|
By default, labels are global, which
means that they can be "seen" from anywhere in your program. Sometimes,
however, you may want to use a local label, which can only be "seen"
within a limited part of your program (the area in which the local label can be
seen starts at the preceding global label, and continues up to the following
global label).
Local labels have the same syntax rules as
global labels, except they must begin with a colon (:), and must be referenced
with a colon. Local labels can be referenced from from outside their normal
area by referring to preceding global label name:local label name.
The following code demonstrates how to use the
local label :loop for common looping purposes within two globally-labeled
routines.
(global label Routine1)
Routine1 mov count,#100
(local label :loop) :loop
call send_a
(jump to line 2)
djnz count,:loop
ret
(global label Routine2)
Routine2 mov count,#200
(local label :loop) :loop
call send_b
(jump to line 6)
djnz count,:loop
ret
(global label Routine3)
Routine3 mov count,#250
(jump to line 6)
jmp Routine2:loop |