Shop OBEX P1 Docs P2 Docs Learn Events
END? — Parallax Forums

END?

MacGeek117MacGeek117 Posts: 747
edited 2006-06-29 22:51 in Propeller 1
Is there any sort of END command with the Propeller, or will any similar command be made?
RoboGeek

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I reject your reality and subsitute my own!"

Adam Savage, Mythbusters
www.parallax.com
www.goldmine-elec.com
www.expresspcb.com
www.startrek.com
·

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-06-29 02:32
    If you're just looking for a way (while debugging, for example) to block execution of everything following a particular statement, a naked repeat will do the trick. It's also handy at the very end of a block of Spin code to keep the cog from from stopping and tristating its port outputs.
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-06-29 04:36
    Phil says "The end of spin code stops the cog and tristates the ports",
    is the the same as
    "COGSTOP stops a cog whose ID is CogID and places that cog into a dormant state.
    the cog ceases to receive System Clock pulses so that power consumption is greatly reduced." ?

    It dosent mention tristating the outputs.

    Does this mean that this or something like it is added automaticaly at the program end ?

    Can You easily access this end area and display it on the vga monitor?

    Phillip Y.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-06-29 05:19
    Quoting Chip in a different thread [noparse][[/noparse]emphasis mine],
    Chip Gracey said...
    So, you can see that after loading all 512 locations using forced RDLONG instructions, the COG program counter rolls over, right into your code at $000. BTW, the last 16 RDLONGs read 0's, clearing the RAM behind the I/O registers. The DIRA, CTRA, CTRB, and VCFG I/O registers are all cleared asynchronously as long as the COG is inactive (COG reset is held low). This way, as long as (or immediately when) a COG is inactive, its influence completely ceases as its important I/O registers are cleared. When the next program gets loaded, all the registers from $1F0-$1FF get cleared to 0, as well. This means that you can rely on all I/O registers, except the read-only's PAR, CNT, INA, INB, being cleared when your program starts.
  • cgraceycgracey Posts: 14,133
    edited 2006-06-29 06:04
    When a Spin thread runs out, the COG is shut down. This happens because its stack was initialized with a return address of $FFF9, which holds a 3-byte sequence of spin tokens which amount to COGSTOP(COGID). Every time you launch a Spin COG, its stack is initialized in this manner, so that when it runs out, it shuts down.

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


    Chip Gracey
    Parallax, Inc.
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-06-29 06:23
    That explains it from a ASM perspective, COGSTOP is both an asm and spin code function.
    From a SPIN code perspective what instruction token does the COG interpreter program get from main memory after the last user program instruction token ie. the end ?
    This would automaticaly added to the program and not coded by the user.

    I doubt that the spin interperter checks each instruction for the boundary of the program end.
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-06-29 06:38
    So starting a SPIN interpreter cog is done with a CALL and a stack pointer and a pointer to the spincode in main memory ?
  • cgraceycgracey Posts: 14,133
    edited 2006-06-29 10:22
    Phillip,

    This all happens in the Spin interpreter. There is no assembler code running, except what is in the interpreter. These byte codes that get executed as Spin get picked up from main memory. The interepreter doesn't know anything about program boundaries reaching the end. It just does a Spin return·after the·Spin code runs out and that return points to a three-byte sequence in ROM which, when executed as Spin code,·makes the interepreter stop itself.

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


    Chip Gracey
    Parallax, Inc.
  • MacGeek117MacGeek117 Posts: 747
    edited 2006-06-29 22:51
    Thank you, Chip!
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
    ·
Sign In or Register to comment.