I have a program with two data tables and a result table
ORG $B000
TABLE1 FCB 222, 37, ...
TABLE2 FCB 37, 100, ...
ORG $B010
RESULT RMB 8
My program loops through the values in each table and passes them to a function which finds their greatest common denominator. The returned value is passed over the stack and needs to be stored in the Result table. Here is what I have so far
ORG $C000
LDX #TABLE1
LDY #TABLE2
WHILE LDAA 0,X WHILE (*TABLE1 != -1)
CMPA #$FF
BEQ ENDWHILE
LDAA 0,X PASS VARIABLES TO
LDAB 0,Y SUBROUTINE IN REGISTER
INX TABLE1++
INY TABLE2++
JSR SUB
PULA
STAA RESULT GET RETURN VALUE FROM STACK
The above code is working properly as is my subroutine. I can't figure out how to increment my RESULT variable. I tried using a loop counter as an offset but for some reason the below code stores at location $B019 instead of $B010
STAA COUNTER,RESULT
INC COUNTER
If anything is unclear or if you think the question is bad please comment and I will fix it.