| |
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 ! |
|
| |
chatGPZ
Registered: Dec 2001 Posts: 11114 |
what are you actually trying to do?
.var command may or may not be what you are looking for |
| |
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. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11114 |
.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 :) |
| |
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. |
| |
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 ! |