Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in 
CSDb User Forums


Forums > C64 Coding > 64tass: labels inside FOR ... NEXT loops
2016-12-01 15:45
ready.

Registered: Feb 2003
Posts: 427
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
.....
 
... 13 posts hidden. Click here to view all posts....
 
2016-12-03 14:56
Compyx

Registered: Jan 2005
Posts: 432
Quoting soci
The "^" 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.
2016-12-03 16:07
soci

Registered: Sep 2003
Posts: 424
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...
2016-12-03 18:29
Compyx

Registered: Jan 2005
Posts: 432
Sorry, I meant ^start of course.

Personally I'd rather break stuff now than later if it makes sense. Keeping old cruft around doesn't make maintaining things easier.
Deprecation warnings only serve to have people think "I'll fix that later", which they only do when stuff actually breaks.
2016-12-03 20:49
soci

Registered: Sep 2003
Posts: 424
It's not a maintenance issue as the code implementing it was refactored a few times already and is not much.

The concern is that the de facto standard notation for bank bytes still can't be used while there was a 100% replacement for years to create the exact same strings (and more).

I've added the warning for now as it helps to identify what needs to be changed and how. Especially that the breakage is hard to spot in some cases. Then sometime next year or so "^xxx" will be changed to calculate the bank bytes instead.
2016-12-03 20:52
Groepaz

Registered: Dec 2001
Posts: 9090
Quote:
Keeping old cruft around doesn't make maintaining things easier.

you only say that because you don't like it =P
2019-02-21 14:22
ready.

Registered: Feb 2003
Posts: 427
How could I use the same list feature but in a matrix way, so that lista is a matrix and no just a vector?
2019-02-21 20:14
soci

Registered: Sep 2003
Posts: 424
Matrixes are just nested lists.
m = [[1,2],[3,4]]

lda #m[0,0]
2019-02-21 20:27
soci

Registered: Sep 2003
Posts: 424
Btw. in 1.54 I've added scoped loop directives. Now the second example in post #5 can be simplified to:
        *= $1000

lista   .bfor i = 0, i < 8, i += 1
label   lda #i
        .if i > 3
lbl2    nop
        .fi
        .next

        .word lista.label ; all labels
        .word lista[4].lbl2 ; the one from the 5th run
2019-02-22 07:27
oziphantom

Registered: Oct 2014
Posts: 274
This new feature is handy for avoiding the "I used a" trap ;)

aka

.for a = 0, a < 10 , a += 2

then later

lsr a

.warning Invalid addressing mode
2019-02-22 08:48
soci

Registered: Sep 2003
Posts: 424
The loop related calculations are not scoped. This is so you can update an existing variable created somewhere above and that the loop variable is available later for checks/further continuation loops.

Such unfortunate name choices should be avoided. Using -Wshadow can help with that.
Previous - 1 | 2 | 3 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
bugjam
Alakran_64
razorback/G★P
WVL/Xenon
Dymo/G★P
Snabel
Sentinel/Excess
kms
hedning/G★P
redcrab/G★P
AJOT
Guests online: 43
Top Demos
1 Uncensored  (9.7)
2 Unboxed  (9.7)
3 Edge of Disgrace  (9.7)
4 Coma Light 13  (9.6)
5 Comaland 100%  (9.6)
6 Lunatico  (9.6)
7 The Shores of Reflec..  (9.6)
8 X Marks the Spot  (9.5)
9 Old Men in Used Cars  (9.5)
10 C=Bit 18  (9.5)
Top onefile Demos
1 Bad Boy  (9.7)
2 Smile to the Sky  (9.6)
3 Daah, Those Acid Pil..  (9.5)
4 Dawnfall V1.1  (9.4)
5 FMX Music Demo  (9.4)
6 Rewind  (9.4)
7 Crystal Gazer  (9.4)
8 Official X2018 Report  (9.4)
9 Arok 20 Invitation  (9.4)
10 Pandemoniac Part 2 o..  (9.4)
Top Groups
1 PriorArt  (9.7)
2 Oxyron  (9.5)
3 Booze Design  (9.4)
4 Censor Design  (9.3)
5 Performers  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.9)
2 Veto  (9.8)
3 Jailbird  (9.6)
4 Mirage  (9.6)
5 Pal  (9.5)

Home - Disclaimer
Copyright © No Name 2001-2019
Page generated in: 0.056 sec.