Shop OBEX P1 Docs P2 Docs Learn Events
Run assembler routine in a spin program? — Parallax Forums

Run assembler routine in a spin program?

prof_brainoprof_braino Posts: 4,313
edited 2010-06-15 15:56 in Propeller 1
A spin program that runs in a single cog a has bottleneck inside the main loop. sad.gif

Is it possible to optimize just the bottleneck portion in assembly, and still have the remainder of the program in spin, and still run in a single cog?

How does one call the assembly routine from spin? Is there an example of this in the object exchange?

Thanks!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There are 10 types of people in the world,
Those who understand binary, and those who don't

Comments

  • JasonDorieJasonDorie Posts: 1,930
    edited 2010-06-15 03:38
    Nope - Can't be done. The SPIN interpreter itself takes the full memory space of the cog it runs in, so executing PASM in the same cog isn't possible, and there's no support for such a thing in SPIN.

    That said, there's a decent chance you may be able to optimize the SPIN itself to make it faster - The compiler makes no attempt to optimize your code. Post the routine in question (attach the code to a reply, for simplicity) and someone may be able to suggest improvements. Assuming it's reasonably close to the goal to begin with.

    Jason
  • RossHRossH Posts: 5,519
    edited 2010-06-15 04:10
    prof_braino said...
    A spin program that runs in a single cog a has bottleneck inside the main loop.

    Of course - so why do it? One of SPIN's major advantages over many other languages is how easy it makes it to run either a SPIN method or a PASM program concurrently in another cog. If you can redesign your program to take advantage of this parallelism you can partially or completely eliminate this bottleneck. While not all algoritms are amenable to parallelization (is this a word?), most programs can be at least significantly improved.

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-06-15 14:23
    It would be nice if Parallax includes a small LMM interpreter within the Spin interpreter for the Prop II.· This way a Spin program could·execute some inline assembly along with the Spin code.· I have thought about modifying the current interpreter by replacing the SQRT code with an LMM interpreter, but I haven't gotten around to it.· Of course, this would require reloading the cog with the modified interpreter after bootup.

    Dave
  • prof_brainoprof_braino Posts: 4,313
    edited 2010-06-15 15:56
    RossH said...
    prof_braino said...
    A spin program that runs in a single cog a has bottleneck inside the main loop.

    Of course - so why do it?

    Ross.

    "Why?" indeed. Just because, usually. This is a hypothetical situation.

    In this case, to a lesser extent, the other cogs might be occupied and/or busy with timing critical functions.

    But mostly because I wanted somebody confirm "it can't be done" so I have something to ponder for a while. Thanks Jason.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people in the world,
    Those who understand binary, and those who don't
Sign In or Register to comment.