| |
ready.
Registered: Feb 2003 Posts: 441 |
64tass: labels inside FOR ... NEXT loops
hello,
does 64tass have the possibility to use indexed labels, like inside a FOR...NEXT loop?
Something like:
.FOR X=0, X<X_MAX-1, X=X+1
LABEL(X)
LDA #ABC
STA ZXY
.NEXT
so to have X_MAX labels.
Unrolled:
LABEL1
LDA #ABC
STA ZXY
LABEL2
LDA #ABC
STA ZXY
..... |
|
... 18 posts hidden. Click here to view all posts.... |
| |
soci
Registered: Sep 2003 Posts: 473 |
Thanks! Next time I'll comment in English, one can never know ;) |
| |
Radiant
Registered: Sep 2004 Posts: 639 |
Parenthetical: A great example of why code comments and symbols always should be in English - you never know who is going to read the code down the line.
I take it one step further and keep all design documents, Trello boards et cetera in English as well, even though at the moment everyone in the group speaks Swedish. |
| |
Oswald
Registered: Apr 2002 Posts: 5017 |
*= $801
.word +, 2016
.null $9e, ^start
+ .word 0
start
sei
lda #<irqlist[0].addr ; first adress
sta $314
lda #>irqlist[0].addr
sta $315
lda #irqlist[0].raster ; first raster pos
sta $d012
lda $d011
and #~$80
sta $d011
lda #1
sta $dc0d
sta $d01a
bit $dc0d
sta $d019
cli
rts
irqlist2 := [] ; empty list for the routines
.for this = 0, this < 50, this = this + 1; 50 pcs
irqlist2 ..= [+] ;put current irq routine into list
+ .block ; irq routine block
addr = * ; address
raster = (this & 1) == 0 ? (this/2)*8+53 : (this/2)*8+55; raster position for effect
nextirq = irqlist[len(irqlist2) % len(irqlist)];the next irq routine
lda #this & 15 ; so some effect is shown
sta $d020
lda #nextirq.raster ; next position
sta $d012
inc $d019
lda #<nextirq.addr ; next adress
sta $314
.if (>nextirq.addr) != (>addr); only if needed
lda #>nextirq.addr
sta $315
.fi
jmp this == 49 ? $ea31 : $ea81; so you can type ;)
.bend
.next
irqlist = irqlist2 ; so it is possible to use up there |
| |
chatGPZ
Registered: Dec 2001 Posts: 11114 |
Quote:A great example of why code comments and symbols always should be in English
come on.... at least its not japanese :) |
| |
Hein
Registered: Apr 2004 Posts: 933 |
Quoting soci
*= $1000
lista := [] ; empty
.for i=0,i<8,i=i+1
lista ..= [*] ; collect
lda #i
.if i>3
nop
.fi
.next
.word lista ;all
.word lista[4];5th
Thanks, will try that. |
| |
Oswald
Registered: Apr 2002 Posts: 5017 |
soci, could you explain the ..= operator? |
| |
Flavioweb
Registered: Nov 2011 Posts: 447 |
Quote: soci, could you explain the ..= operator?
http://tass64.sourceforge.net/#compound |
| |
soci
Registered: Sep 2003 Posts: 473 |
Yes, "..=" is the compound assignment version of the concatenate operator "..".
So "a ..= b" is the shorter form of "a := a .. b" or "a .var a .. b". Just like "a += b" is "a := a + b".
Btw. compound assignments for ".for" loops are only available since r1245. The last release was r1237 which is the reason I still used "i = i + 1" instead of the shorter "i += 1" in the example. |
| |
Compyx
Registered: Jan 2005 Posts: 631 |
Quoting sociThe "^" prefix for macro parameters is gone since r98. It did an expression evaluation and the result was converted to a decimal string which in turn was used for textual replacement. Similar to the "^" operator.
While it could be resurrected I'd like to see it dead and buried. Unfortunately the non-macro operator variant of this can't go away that easy due to it's common use in basic start lines. The sad thing is there's no other useful use of it at all. It should have been assigned as the bank byte operator but it couldn't due to it's 1.3x legacy.
Why not remove it, with an error message when people use it. I'm sure I can change ^2016 to .text "2061" or something like it in my sources if 64tass borks and prints a clear message. |
| |
soci
Registered: Sep 2003 Posts: 473 |
Normally it isn't used as '^2061' directly, but more as '^start'. An equivalent replacement is 'format("%d", start)' as that's what it does.
Possibly I can make a deprecation warning which directs to the use of format function instead.
It can't be changed to mean the bank byte immediately as it will compile without error if ".text $9e, ^start" was used. For ".null $9e, ^start" of course not as the result is likely 0 which is an error.
So there needs to be at least one release with the warning before it could change. And then the current "`" bank byte operator needs be there for even longer as an alias. But that's not a big problem as it's like the old "//" alias for modulo (now "%") and there's no plan to reuse it for something else yet.
Edit: It seems I have more than ~450 instances of ^xxx of which only ~50 or so is ^year, ^revision and such, rest is ^start. Oh well... |
Previous - 1 | 2 | 3 | 4 - Next |