Documented the .SET operator that has been available for about 6 years now :-)
git-svn-id: svn://svn.cc65.org/cc65/trunk@5309 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
494b0619d7
commit
0d04730ddf
1 changed files with 66 additions and 33 deletions
|
@ -696,6 +696,39 @@ The right side can of course be an expression:
|
|||
</verb></tscreen>
|
||||
|
||||
|
||||
<label id=".SET">
|
||||
<sect1>Numeric variables<p>
|
||||
|
||||
Within macros and other control structures (<tt><ref id=".REPEAT"
|
||||
name=".REPEAT"></tt>, ...) it is sometimes useful to have some sort of
|
||||
variable. This can be achieved by the <tt>.SET</tt> operator. It creates a
|
||||
symbol that may get assigned a different value later:
|
||||
|
||||
<tscreen><verb>
|
||||
four .set 4
|
||||
lda #four ; Loads 4 into A
|
||||
four .set 3
|
||||
lda #four ; Loads 3 into A
|
||||
</verb></tscreen>
|
||||
|
||||
Since the value of the symbol can change later, it must be possible to
|
||||
evaluate it when used (no delayed evaluation as with normal symbols). So the
|
||||
expression used as the value must be constant.
|
||||
|
||||
Following is an example for a macro that generates a different label each time
|
||||
it is used. It uses the <tt><ref id=".SPRINTF" name=".SPRINTF"></tt> function
|
||||
and a numeric variable named <tt>lcount</tt>.
|
||||
|
||||
<tscreen><verb>
|
||||
.lcount .set 0 ; Initialize the counter
|
||||
|
||||
.macro genlab
|
||||
.ident (.sprintf ("L%04X", lcount)):
|
||||
lcount .set lcount + 1
|
||||
.endmacro
|
||||
</verb></tscreen>
|
||||
|
||||
|
||||
<sect1>Standard labels<p>
|
||||
|
||||
A label is defined by writing the name of the label at the start of the line
|
||||
|
|
Loading…
Add table
Reference in a new issue