NASM gives special treatment to symbols beginning with a period. A label beginning with a single period is treated as a local label, which means that it is associated with the previous non-local label. So, for example:
label1 ; some code .loop ; some more code jne .loop ret label2 ; some code .loop ; some more code jne .loop ret
In the above code fragment, each JNE
instruction jumps to
the line immediately before it, because the two definitions of .loop
are kept separate by virtue of each being associated with the
previous non-local label.
NASM goes one step further, in allowing access to local labels from other parts of the
code. This is achieved by means of defining a
local label in terms of the previous non-local label: the first definition of
.loop
above is really defining a symbol called label1.loop
, and the second defines a symbol called label2.loop
. So, if you really needed to, you could write
label3 ; some more code ; and some more jmp label1.loop
Sometimes it is useful - in a macro, for
instance - to be able to define a label which can be referenced from anywhere but which
doesn’t interfere with the normal local-label mechanism. Such a label can’t be
non-local because it would interfere with subsequent definitions of, and references to,
local labels; and it can’t be local because the macro that defined it wouldn’t know
the label’s full name. NASM therefore introduces a third type of label, which is
probably only useful in macro definitions: if a label begins with the special prefix
..@
, then it does nothing to the local label mechanism. So
you could code
label1: ; a non-local label .local: ; this is really label1.local ..@foo: ; this is a special symbol label2: ; another non-local label .local: ; this is really label2.local jmp ..@foo ; this will jump three lines up
NASM has the capacity to define other special symbols beginning with a double period:
for example, ..start
is used to specify the entry point in
the obj
output format.