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

Registered: Dec 2001
Posts: 9318
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
Groepaz

Registered: Dec 2001
Posts: 9318
.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: 443
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
Sentinel/Excess
Jazzcat/Onslaught
hqn/Silicon Ltd
alwyz/udi
Guests online: 41
Top Demos
1 Coma Light 13  (9.7)
2 Uncensored  (9.7)
3 Edge of Disgrace  (9.7)
4 Comaland 100%  (9.6)
5 Unboxed  (9.6)
6 The Shores of Reflec..  (9.6)
7 Lunatico  (9.5)
8 Remains  (9.5)
9 NGC 1277 100%  (9.5)
10 Wonderland XII  (9.4)
Top onefile Demos
1 Dawnfall V1.1  (9.6)
2 Listen to Your Eyes  (9.6)
3 MD202006 - Get Well ..  (9.6)
4 The Tuneful Eight [u..  (9.5)
5 Smile to the Sky  (9.5)
6 Crystal Gazer  (9.5)
7 Instinct  (9.5)
8 Coro(l)na Nuthouse  (9.5)
9 Rewind  (9.5)
10 Bad Boy  (9.5)
Top Groups
1 PriorArt  (9.6)
2 Performers  (9.5)
3 Booze Design  (9.4)
4 Fossil  (9.4)
5 Censor Design  (9.4)
Top Organizers
1 Tim  (10)
2 cTrix  (10)
3 Retroluzzer  (10)
4 Burglar  (9.9)
5 Sixx  (9.9)

Home - Disclaimer
Copyright © No Name 2001-2020
Page generated in: 0.039 sec.