Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user maak ! (Registered 2024-04-18) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > KickAss coding question
2015-01-03 20:31
xIII

Registered: Nov 2008
Posts: 210
KickAss coding question

If I use a for loop and load a value from a table which is stored to a label inside the for loop the value is always the first value of the table ?

just an example:
.for (var i=0; i<38; i++) {

lda valuefromtable+i
sta store+1

store:
lda #$00
sta $d020
}
rts

valuefromtable: .byte 0,1,2,3,4,5,6,7,8,9,10

Question: how can this be solved ? or what am I doing wrong ?
 
... 5 posts hidden. Click here to view all posts....
 
2015-01-03 22:43
Knut Clausen

Registered: Apr 2013
Posts: 18
My guess is that you need to have another look at how the kickassembler preprocessing works. Once you do that, your output will make sense.

I'm not sure what you want to accomplish, but here are two possible solutions.
1: Load numbers by memory reference:

.for (var i=0; i<11; i++) {
lda valuefromtable+i
sta $d020
}
rts
valuefromtable: .byte 0,1,2,3,4,5,6,7,8,9,10

2: Load numbers by actual value:

.var colorsList = List()
.eval colorsList.add(0,1,2,3,4,5,6,7,8,9,10 )
.for (var i=0; i<colorsList.size(); i++) {
lda # colorsList.get(i)
sta $d020
}
rts
2015-01-03 22:50
Oswald

Registered: Apr 2002
Posts: 5017
or how the big boys do it:

lda #<speed
sta fc
lda #>speed
sta fd

lda #$00
sta i

loop

ldx i
lda table,x
sta mod+1

ldy #$00
copy
lda sample,y
sta (fc),y
iny
cpy #end-start
bne copy

tya
clc
adc fc
sta fc
bcc *+4
inc fd

inc y
lda y
cmp #38
bne loop

ldy #$00
lda #$60
sta (fc),y
rts

sample
start
mod lda #$00
sta $d020
end

table .byte 0,1,2,3,4,5,6,7
2015-01-03 22:51
Cruzer

Registered: Dec 2001
Posts: 1048
xIII: The result you get in the Vice monitor seems correct. My guess is now that the code hasn't been executed yet, and the values from the table therefore haven't been copied to the lda's.
2015-01-03 22:55
Oswald

Registered: Apr 2002
Posts: 5017
the first problem that we dont even know whats the problem...

I think kickass is to be used by experienced programmers (such as myself), if you cant write the code generator in native assembly its not for you.

inc i instead of inc y btw.
2015-01-04 10:17
Ash Checksum

Registered: Nov 2013
Posts: 6
Word. I think also cars should be only used by people who can build an engine.
2015-01-04 11:08
Mixer

Registered: Apr 2008
Posts: 421
Quote: Word. I think also cars should be only used by people who can build an engine.

I like that sentence, because it is so true.
2015-01-04 11:09
Oswald

Registered: Apr 2002
Posts: 5017
if you dont learn your shit, then you will end up putting up questions like the above.

especially the dissassembly, and not understanding kickass did exactly what he was asking for is like a disaster. its not like he cant build an engine, he doesnt even knows which pedal does what.
2015-01-04 11:30
xIII

Registered: Nov 2008
Posts: 210
@Cruzer/Burglar: I was expecting a different value after LDA when I checked the result of the parsing by Kickass. But I know now that the code is OK once I run it!

Just add this question to the list: 'stupid coding questions by xIII' ;)

Knut: thanks

Nith: it was just a fast example.

Oswald: Maybe... one day... if I keep trying... if I keep asking... I'll be a big boy too... maybe... probably not... but maybe... ok... not... but I don't care :)
2015-01-04 11:30
Burglar

Registered: Dec 2004
Posts: 1031
@oswald, isnt learning exactly what he's trying to achieve?

experienced coders (such as myself) don't mind giving noob coders some explanations and pointers ;)
2015-01-04 12:05
Oswald

Registered: Apr 2002
Posts: 5017
me too, but its frustrating when the asker disappears, and leaves us here wondering what he even wanted :)

knut has the right answers.
Previous - 1 | 2 - 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
Edhellon/Resource
Alakran_64
pitfallharry_de
deetsay
Ziili/Extend
Vg Vox/Voxvideogame
megasoftargentina
CreaMD/React
Guests online: 111
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 Wonderland XIV  (9.6)
9 The Ghost  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.9)
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 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (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 NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

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