Shop OBEX P1 Docs P2 Docs Learn Events
Write from assembly to spin — Parallax Forums

Write from assembly to spin

PrincPrinc Posts: 12
edited 2013-11-22 15:22 in Propeller 1
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

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-11-22 06:33
    You just need to send the first address like ...

    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 element
    

    For 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 element
    

    For 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
    
  • edited 2013-11-22 15:22
    This thread is moving to the Propeller forum.
Sign In or Register to comment.