mirror of
https://github.com/cc65/cc65.git
synced 2024-09-21 10:37:28 +00:00
Document changes in unnamed labels.
This commit is contained in:
parent
c500cb9086
commit
270f3544b5
@ -829,49 +829,42 @@ names like "Loop". Here is an example:
|
|||||||
bne @Loop ; ERROR: Unknown identifier!
|
bne @Loop ; ERROR: Unknown identifier!
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
|
|
||||||
<sect1>Unnamed labels<p>
|
<sect1>Unnamed labels<p>
|
||||||
|
|
||||||
If you really want to write messy code, there are also unnamed labels. These
|
If you really want to write messy code, there are also unnamed labels. To define
|
||||||
labels do not have a name (you guessed that already, didn't you?). A colon is
|
an unnamed label, use either <tt>@:</tt> (<tt>.LOCALCHAR</tt> is respected if it
|
||||||
used to mark the absence of the name.
|
is set) or sole <tt>:</tt>.
|
||||||
|
|
||||||
Unnamed labels may be accessed by using the colon plus several minus or plus
|
To reference an unnamed label, use <tt>@</tt> (<tt>.LOCALCHAR</tt> is respected
|
||||||
characters as a label designator. Using the '-' characters will create a back
|
if it is set) or <tt>:</tt> with several <tt>-</tt> or <tt>+</tt> characters.
|
||||||
reference (use the n'th label backwards), using '+' will create a forward
|
The <tt>-</tt> characters will create a back reference (n'th label backwards),
|
||||||
reference (use the n'th label in forward direction). An example will help to
|
the <tt>+</tt> will create a forward reference (n'th label in forward direction).
|
||||||
understand this:
|
As an alternative, angle brackets <tt><</tt> and <tt>></tt> may be used
|
||||||
|
instead of <tt>-</tt> and <tt>+</tt> with the same meaning.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
: lda (ptr1),y ; #1
|
cpy #0
|
||||||
cmp (ptr2),y
|
beq @++
|
||||||
bne :+ ; -> #2
|
@:
|
||||||
tax
|
sta $2007
|
||||||
beq :+++ ; -> #4
|
dey
|
||||||
iny
|
bne @-
|
||||||
bne :- ; -> #1
|
@:
|
||||||
inc ptr1+1
|
rts
|
||||||
inc ptr2+1
|
|
||||||
bne :- ; -> #1
|
|
||||||
|
|
||||||
: bcs :+ ; #2 -> #3
|
|
||||||
ldx #$FF
|
|
||||||
rts
|
|
||||||
|
|
||||||
: ldx #$01 ; #3
|
|
||||||
: rts ; #4
|
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
As you can see from the example, unnamed labels will make even short
|
Unnamed labels may make even short sections of code hard to understand, because
|
||||||
sections of code hard to understand, because you have to count labels
|
you have to count labels to find branch targets. It's better to prefer the
|
||||||
to find branch targets (this is the reason why I for my part do
|
"cheap" local labels. Nevertheless, unnamed labels are convenient in some
|
||||||
prefer the "cheap" local labels). Nevertheless, unnamed labels are
|
situations, so it's up to your discretion.
|
||||||
convenient in some situations, so it's your decision.
|
|
||||||
|
|
||||||
<em/Note:/ <ref id="scopes" name="Scopes"> organize named symbols, not
|
<em/Note:/ <ref id="scopes" name="Scopes"> organize named symbols, not
|
||||||
unnamed ones, so scopes don't have an effect on unnamed labels.
|
unnamed ones, so scopes don't have an effect on unnamed labels.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sect1>Using macros to define labels and constants<p>
|
<sect1>Using macros to define labels and constants<p>
|
||||||
|
|
||||||
While there are drawbacks with this approach, it may be handy in a few rare
|
While there are drawbacks with this approach, it may be handy in a few rare
|
||||||
|
Loading…
Reference in New Issue
Block a user