PROC + ASM noob problem
frenchfaso opened this issue · 2 comments
Hy there,
thanks for this beautiful language, I'm really enjoying the gentle approach to asm that it enables!
I'm trying to write a proc in asm that changes border and/or background color like this:
proc change_color(addr, col!)
asm "
lda {self}.col
sta {self}.addr
"
endproc
for i! = 0 to 15
call change_color(53280, i!)
call change_color(53281, i!)
for t = 0 to 10000
rem slow down a bit...
next t
next i!
it compiles without errors and it also runs without problems, but neither color does change!
If I put the address directly in the asm part, it works:
asm "
lda {self}.col
sta 53280
sta 53281
"
I'm surely missing something here...
Thanks for your help!
Hi. The problem here is that {self}.addr
refers to the variable addr
, not to the value that it holds. You'll need indirect addressing, something like this (not tested but I think you'll get the idea):
proc change_color(addr, col!)
asm "
; move the value of addr to the zeropage
; note R0 is a ZP address that is safe to use here
lda {self}.addr
sta R0
lda {self}.addr + 1
sta R0 + 1
; move col! to A
lda {self}.col
ldy #0
sta (R0),y
"
endproc
Good luck!
Thank you!
that did the trick, seems like I have plenty to learn about 6510 ML :-)