Shop OBEX P1 Docs P2 Docs Learn Events
Running a PASM code without starting a new cog. — Parallax Forums

Running a PASM code without starting a new cog.

OctahedronOctahedron Posts: 18
edited 2010-03-27 21:15 in Propeller 1
I wish to run a quick·PASM routine occasionally and I don’t want to start up the·PASM in another cog.· Is this possible?· Any examples?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Comments

  • potatoheadpotatohead Posts: 10,261
    edited 2010-03-26 03:12
    It's not really possible. PASM code only executes in the COG, and only after the COG has been started, and it's memory space copied from the HUB.

    You have some choices though. One is to setup a service cog that contains a lot of routines, or maybe just that routine that will run when instructed to.

    What you do is setup a few HUB memory locations, that can hold values for the routine to use, or addresses to use, and one other location to control execution.

    Write a 0 to the control address, then fire up the cog. It waits until non zero, then runs the routine desired according to the value, and the routine writes a 0 when it's done.

    Then, when it's time to run something, you load up the HUB memory locations, write the value for the routine, the service cog runs it, and writes a 0 when done.

    In your program, you set the value, after loading the HUB, then either wait on 0 to continue, or if things can be done in parallel, let your program go off and do something else, eventually syncing up with the 0 value to know the routine has finished. If the non-zero value is there, you know the routine is still busy.

    It's not possible to "in-line" assembly with SPIN, because the COG running the SPIN program is busy doing that, and is full, capable of nothing else. Another COG is needed for this.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    8x8 color 80 Column NTSC Text Object
    Safety Tip: Life is as good as YOU think it is!
  • OctahedronOctahedron Posts: 18
    edited 2010-03-27 21:15
    Thanks for the feedback. As always it is appreciated!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.