Shop OBEX P1 Docs P2 Docs Learn Events
Newbie ASM Question-Resolved — Parallax Forums

Newbie ASM Question-Resolved

tom90tom90 Posts: 55
edited 2009-02-26 17:23 in Propeller 1
Hey All,

Can I make arrays in asm and pass them to cogs running spin? I want to continually write word sized data into 150 memory spaces until i tell it to stop, then i can manipulate the data in the 150 words. Can i make an array of 150 words in asm, and if so how?

Thanks
Tom

Post Edited (tom90) : 2/24/2009 8:40:26 PM GMT

Comments

  • TreeLabTreeLab Posts: 138
    edited 2009-02-24 19:26
    The only way that cog #1 can see what cog #2 is doing or the results of a calculation is if cog #2 sends it out to hub memory with a wrxxx instruction (byte/word/long); presumably, the code running on the two cogs have already agreed on where to store the data in hub so both can get to it. You can reserve space in a cog to store information, but that cog must make it externally visible via the hub.

    Cheers!
    Paul ROwntree
  • AleAle Posts: 2,363
    edited 2009-02-24 19:54
    If you are new to asm, and especially propeller assembler, I'D recommend you have a look at the following thread that has some useful sub-threads linked:
    http://forums.parallax.com/showthread.php?p=786265

    You just declare the array in spin, and give your asm routine (not yet launched) the address via the @ operator:
    var
       my_array_name : long[noparse][[/noparse]150]
    ...
    
    cognew(my_asm_routine, @my_array_name]
    
    ...
    DAT
        org
    my_asm_routine
        mov ptr_to_array, PAR    ' PAR contains the value passed via cognew
    
    ...
    
    ptr_to_array    long   0    ' Variable that will contain the value in PAR
    
    
    



    There are other ways
  • tom90tom90 Posts: 55
    edited 2009-02-24 20:37
    Thanks Everyone,

    Ale, i have already used the parameter for another variable (I should have mentioned this in my first post). That being said, I think I figured out how to take care of my problem without using an array.

    Thanks for your responses.
    Tom
  • AleAle Posts: 2,363
    edited 2009-02-24 21:11
    When you have not yet launched your asm code, you can write to ptr_to_array directly, and so avoid the use of the PAR for that, like in the VGA examples by Chip Gracey (obex).
  • schwiegjcschwiegjc Posts: 41
    edited 2009-02-24 21:45
    To move data from ASM to SPIN

    wrlong value, par

    If the variable address is an array, then how do you reference the other indexes of the array

    I have tried, but it did not work

    wrlong value, par+1
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-02-26 17:23
    Hi schwiegjc, I was kind of curious about that myself and came up with this solution but I'm unsure if it's the right solution.

    ·········· mov ptr_to_array, PAR
    ···········add ptr_to_array,#1····· 'reference to array element [noparse][[/noparse]1]
    ···········wrbyte number,ptr_to_array

    ······· ptr_to_array·· long·· 0


    @those who are skilled with ASM is this the right way?

    thanks

    Jeff T.

    EDIT: the above is not the original solution I posted , I walked away from the computer and realized I had unwittingly answered my own question ( I think ). I too was at first trying to solve it using the "+" operater , a mild case of tunnel vision. If the above is indeed correct I see it is a considerable advancement , for now with using Spin and a serial object I can debug the results of sample asm code to a terminal.


    Post Edited (Unsoundcode) : 2/26/2009 7:46:06 PM GMT
Sign In or Register to comment.