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: 438
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
.....
 
... 15 posts hidden. Click here to view all posts....
 
2016-12-03 18:29
Compyx

Registered: Jan 2005
Posts: 470
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: 438
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: 9100
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: 438
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: 438
Matrixes are just nested lists.
m = [[1,2],[3,4]]

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

Registered: Sep 2003
Posts: 438
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: 351
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: 438
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.
2019-10-02 15:54
ready.

Registered: Feb 2003
Posts: 438
thanks for the replies, they've been really useful.
Now I take it to an even further level.
Let's say I need a multiple index label, so far I only need a vector of labels, thus: LABEL[0], LABEL[1], LABEL[2]....
But how can I implement a matrix of labels, thus
LABEL[0][0], LABEL[0][1],....
LABEL[1][0], LABEL[1][1],...
LABEL[2][0], LABEL[2][1],...
Somthing like:
FRAME := [][][]
.FOR FRAME=0,FRAME<=6,FRAME=FRAME+2
.FOR ZOOM=1,ZOOM<=3,ZOOM=ZOOM+1
FRAME .= [FRAME],[ZOOM]
.binary .....
.NEXT
.NEXT
2019-10-02 17:12
soci

Registered: Sep 2003
Posts: 438
You need to nest them. For the exact style you want:
FRAMES := []
.FOR FRAME=0, FRAME<=6, FRAME += 2
 ZOOMS := []
 .FOR ZOOM=1, ZOOM<=3, ZOOM += 1
  - .binary .....
  ZOOMS ..= [-] ; collect in zooms
 .NEXT
 FRAMES ..= [ZOOMS] ; collect zooms in frames
.NEXT

lda #<FRAMES[2][0]
ldx #>FRAMES[2][0]
However I would do this instead:
FRAMES .BFOR FRAME IN RANGE(0, 7, 2)
 ZOOMS .BFOR ZOOM IN RANGE(1, 4)
  .binary .....
 .NEXT
.NEXT

lda #<FRAMES[2].ZOOMS[0]
ldx #>FRAMES[2].ZOOMS[0]
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
Radd Maxx/SWIM
Brataccas/HF
Durandal
Guests online: 83
Top Demos
1 Uncensored  (9.7)
2 Unboxed  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.7)
5 Comaland 100%  (9.6)
6 Lunatico  (9.6)
7 The Shores of Reflec..  (9.5)
8 Rivalry  (9.5)
9 C=Bit 18  (9.5)
10 X Marks the Spot  (9.5)
Top onefile Demos
1 Instinct  (9.6)
2 Crystal Gazer  (9.6)
3 The Tuneful Eight [u..  (9.5)
4 Dawnfall V1.1  (9.5)
5 Smile to the Sky  (9.5)
6 Space Demo  (9.5)
7 Field Sort  (9.5)
8 Je t'aime mon Monstre  (9.5)
9 The Tuneful Eight (U..  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.5)
2 Fossil  (9.4)
3 PriorArt  (9.4)
4 Booze Design  (9.4)
5 Arsenic  (9.4)
Top Crackers
1 Mr. Z  (10)
2 S!R  (9.8)
3 Mr Zero Page  (9.7)
4 Janitor  (9.7)
5 Mitch  (9.6)

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