1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-28 19:29:53 +00:00

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:
uz 2011-12-10 12:09:46 +00:00
parent 494b0619d7
commit 0d04730ddf

View File

@ -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