Write from assembly to spin
Hi,
I would like to ask you how can i write from assembly to VAR blok (spin)
I made a field for example
long color[253]
i want to write from assembly to spin
I know that i can send address for cognew like cognew(@writetospin,@colors[253])
or i can write to it with wrlong from assembly
but if i want to write for example to position 143 i don´t know any easy trick how to do it beacause i know that assembly doesn´t have anything like arrrays
thanks a lot
I would like to ask you how can i write from assembly to VAR blok (spin)
I made a field for example
long color[253]
i want to write from assembly to spin
I know that i can send address for cognew like cognew(@writetospin,@colors[253])
or i can write to it with wrlong from assembly
but if i want to write for example to position 143 i don´t know any easy trick how to do it beacause i know that assembly doesn´t have anything like arrrays
thanks a lot

Comments
cognew(@writetospin,@colors)
...inside of the Assembly program the address that you specify in "@colors" is moved to the par variable.
It is important to know that the par variable is always LONG aligned, but accessed by each individual byte within the PASM.
Depending on how you defined "@colors" .... i.e. BYTE, WORD, LONG, will depend on how you will want to access the proper array element within PASM.
Note: to write to an element in an array, simply use the wrbyte, wrword, and wrlong in place of the rdbyte,rdword, and rdlong below.
For example if "@colors" were defined as a BYTE:
mov t1, par 'use temp variable t1 to hold value of par ; array address rdbyte val1, t1 'read contents of first array element add t1, #1 'increment to next array address rdbyte val2, t1 'read contents of second array element add t1, #1 'increment to next array address rdbyte val3, t1 'read contents of third array elementFor example if "@colors" were defined as a WORD: (notice the difference in what we add to t1)
mov t1, par 'use temp variable t1 to hold value of par ; array address rdword val1, t1 'read contents of first array element add t1, #2 'increment to next array address rdword val2, t1 'read contents of second array element add t1, #2 'increment to next array address rdword val3, t1 'read contents of third array elementFor example if "@colors" were defined as a LONG: (notice the difference in what we add to t1)
mov t1, par 'use temp variable t1 to hold value of par ; array address rdlong val1, t1 'read contents of first array element add t1, #4 'increment to next array address rdlong val2, t1 'read contents of second array element add t1, #4 'increment to next array address rdlong val3, t1 'read contents of third array element