Propeller Manual

Table Of Contents
Assembly Language Reference
Global and Local Labels
To give names to special routines, Propeller Assembly code can make use of two types of
labels: global and local.
Global labels look just like other symbols and follow the same rules as symbols; they begin
with an underscore ‘
_’ or a letter and are followed by more letters, underscores, and/or
numbers. See Symbol Rules, page 45, for more information.
Local labels are similar to global labels except they start with a colon ‘
:’ and must be
separated from other same-named local labels by at least one global label. Here's an
example:
Addition mov Count, #9 'Set up 'Add' loop counter
:loop add Temp, X 'Iteratively do Temp+X
djnz Count, #:loop 'Dec counter, loop back
Subtraction mov Count, #15 'Set up 'Sub' loop counter
:loop sub Temp, Y 'Iteratively do Temp-Y
djnz Count, #:loop 'Dec counter, loop back
jmp #Addition 'Go add more
This example has two global labels, Addition and Subtraction, and two local labels, both
named
:loop. The local labels can have the exact same name, :loop, because at least one
global label separates them. In fact, this is the point of local labels; they indicate common,
generic things like loops without requiring unique names for each of them.
The two DJNZ instructions are exactly the same, but they each jump to different places. The
Addition routine's DJNZ jumps back to the local label :loop within Addition, and the
Subtraction routine's DJNZ jumps back to the local label :loop within Subtraction.
Note that the
DJNZ instructions use the literal indicator, #, and the exact name of the local
label, including the colon. Without the
# the code would execute improperly (jumping
indirectly rather than directly), and without the colon the code would result in a compile
error. For more Propeller Assembly format information, see Common Syntax Elements, page
250.
Page 242 · Propeller Manual v1.1