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


Forums > C64 Coding > 64tass FOR NEXT
2020-03-30 18:01
B.A.

Registered: Aug 2013
Posts: 5
64tass FOR NEXT

Hi, is it possibel to use 2 "variables" in 1 FOR loop ?

The Code will look like this

.for d_index=0, d_index<10, dindex +=1

lda $8000+( d_index )
sta $2000+( c_index )

.next

all my trys ended up in duplicate bla bla :-/

how i can increase c_index in the same loop ?

Thanks !
2020-03-30 18:11
chatGPZ

Registered: Dec 2001
Posts: 11108
what are you actually trying to do?

.var command may or may not be what you are looking for
2020-03-30 18:26
B.A.

Registered: Aug 2013
Posts: 5
i want to increase d_index +1 and c_index +48 as example in one FOR loop.

lda $8000
sta $2000
lda $8001
sta $2030
lda $8002
sta $2060
...

and so on. this is just an examplecode, i want to know how i can increase two or more "variables" with different increase values in one FOR loop. i dont know if it's possible with FOR. mabey there exists an other solution :-/

thanks.
2020-03-30 18:35
chatGPZ

Registered: Dec 2001
Posts: 11108
.var is one way, if you really need two variables. another is to simply multiply the variable you have, like

lda $1000+i
sta $2000+(i*42)

that said my TASS knowledge is based on the original TASS, not 64tass, it probably can do more :)
2020-03-30 18:41
soci

Registered: Sep 2003
Posts: 473
Define a variable either with ".var" or ":=" and then update it in the loop with ".var", ":=" or with any of the compound operations (e.g. "+=").
c_index := 0  ; 2nd variable initialization
        .for d_index := 0, d_index < 10, dindex +=1
        lda $8000+( d_index )
        sta $2000+( c_index )
c_index += 48 ; increment 2nd variable
        .next
Of course this simple example could be done with one variable only and a multiplication like Groepaz said.

Using more than one variable is only possible in for each style loops. This example assigns a pair of values in a list:
        *= $1000

        .for addr, val in [[$d020, 14], [$d021, 6]]
        lda #val
        sta addr
        .next

        rts
Result:
					*=$1000

					.for addr, val in [[$d020, 14], [$d021, 6]]
.1000	a9 0e		lda #$0e	lda #val
.1002	8d 20 d0	sta $d020	sta addr
.1005	a9 06		lda #$06	lda #val
.1007	8d 21 d0	sta $d021	sta addr
					.next

.100a	60		rts		rts
Btw. if anyone is interested in a built in zip() function please speak up now.
2020-03-30 22:10
B.A.

Registered: Aug 2013
Posts: 5
thanks soci for the help, the

c_index := 0 ; 2nd variable initialization

was the answer of my questions.

thread can be closed, thanks 4 the help !
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
Endurion
zscs
Guests online: 117
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 S!R  (9.9)
3 Mr Zero Page  (9.8)
4 Antitrack  (9.8)
5 OTD  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.044 sec.