Shop OBEX P1 Docs P2 Docs Learn Events
When a Cog runs out of code to run is that like a COGSTOP? — Parallax Forums

When a Cog runs out of code to run is that like a COGSTOP?

Tony B.Tony B. Posts: 356
edited 2009-10-16 16:07 in Propeller 1
As a newbie I am trying to confirm that if a Cog runs out of code to run does it go into sleep mode and is that the same as a COGSTOP?· Reason I ask because if I call another method with COGNEW will it see this Cog as available or should I always use COGSTOP to shutdown a Cog.· Would the condition be the same if I start a Cog with CONINIT and the Cog runs out of code to run?· Will it be seen as available?

Thanks,
Tony

Comments

  • KyeKye Posts: 2,200
    edited 2009-10-16 13:22
    You should use cogstop for clarity. But each stack has the cogstop(cogid) initially pushed on to it already so the cog automatically shutsdown when out of code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • BaggersBaggers Posts: 3,019
    edited 2009-10-16 13:25
    Don't forget if you cogstop all the outputs it had will be zero'd ( and floated if no other cog has them as outputs )

    also, if the cog runs out of code, it'll continue to run, it'll just continue through the cogram executing each location's instruction, unless you have a infinite loop ( here jmp #here ) or cogstop

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-10-16 13:55
    The answer to the original question depends on whether it's an assembly cog or a Spin cog. An assembly cog will just keep cycling through cog memory, executing nonsense instructions after the written instructions leave off — even traipsing through the special registers before starting over at location zero, unless it hits an accidental jmp along the way. A spin cog will simply do a cogstop, unless there's a naked repeat at the end to put it in an infinite loop.

    -Phil
  • ericballericball Posts: 774
    edited 2009-10-16 16:07
    Baggers said...
    Don't forget if you cogstop all the outputs it had will be zero'd ( and floated if no other cog has them as outputs )

    also, if the cog runs out of PASM code, it'll continue to run, it'll just continue through the cogram executing each location's instruction, unless you have a infinite loop ( here jmp #here ) or cogstop
    Or you could use "here waitpeq here, #0" as a low power infinite wait.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
Sign In or Register to comment.