Shop OBEX P1 Docs P2 Docs Learn Events
Carefull with F10 ! — Parallax Forums

Carefull with F10 !

RaymanRayman Posts: 14,877
edited 2010-03-03 06:48 in Propeller 1
I don't know how many times I've accidentally launched a driver .spin file instead of the main one using the Propeller Tool...

It's usually not a problem because nothing happens, and then I realize what I've done.

But, with my RGB matrix driver, I've found that launching the driver by accident can have serious consequences...

Actually, when I look how a lot of assembly drivers are written, thier first PUB routine often launches a new cog based on some argument.
But, the Prop Tool will just compile and launch this code as the MAIN routine even though not given an argument...· It would seems that
some dramatically incorrect things could happen at that point...

I'm starting to think this is not such a good idea...· I think the Prop tool should be smart enough not to launch a spin file
where the first routine has an argument...

Anyway, my workaround is to put in a:

Pub Dummy


line in front of the "Pub Start" line so that nothing happens if you make a mistake and hit F10 while editing this file...

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm

Post Edited (Rayman) : 3/3/2010 1:53:45 AM GMT

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-03 00:45
    Just out of curiosity, what value was plugged into the argument when the method was run via F10?

    -Phil
  • RaymanRayman Posts: 14,877
    edited 2010-03-03 00:48
    I have no idea what happens... Guess it assumes the argument is 0.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

    My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
  • BradCBradC Posts: 2,601
    edited 2010-03-03 01:09
    Phil Pilgrim (PhiPi) said...
    Just out of curiosity, what value was plugged into the argument when the method was run via F10?

    As part of the load the loader zeros all ram, and then creates the 2 longs on the start of the stack. The remainder of the stack stays 0, so when the first pub method is launched all parameters would be 0.

    I stick a pub method up front in all my drivers that puts the driver into a safe test routine. That way I can test the driver while I'm working on it without having to compile the main program, and it's always assured of being in a known, sane state.

    When the main program is compiled, the first pub method in the driver is unreferenced and the compiler simply leaves it out, so there is no memory penalty [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You only ever need two tools in life. If it moves and it shouldn't use Duct Tape. If it does not move and it should use WD40.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-03-03 05:05
    Rayman,

    For this very reason early on it was suggested that the first PUB should be a 'PUB STOP' rather than a 'PUB START' as a means for 'good programming practice'.· It just never really has caught on.· I try to implement the practice·in my own code, but there are sometimes exceptions.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-03 05:08
    So you mean we should stop starting and start stopping?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-03-03 05:17
    Peter Jakacki,

    lol ... nothing is written in stone,· It's just a good programming technique/habit designed·to avoid this particular situation from happening.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Clock LoopClock Loop Posts: 2,069
    edited 2010-03-03 06:17
    Beau Schwabe (Parallax) said...
    Rayman,


    For this very reason early on it was suggested that the first PUB should be a 'PUB STOP' rather than a 'PUB START' as a means for 'good programming practice'. It just never really has caught on. I try to implement the practice in my own code, but there are sometimes exceptions.


    This IS a pretty good idea.

    I myself thought about this situation, and have run programs accidentally like this, but nothing bad happened to my props or parts. And the platform that I was doing this on has leds connected to two prop pins with only 22ohm's of resistance.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-03 06:48
    Sometimes it's useful to name the first PUB routine "demo" and include a short block of code to exercise or demonstrate the object. Just keep it short and simple, so as not to waste a lot of space. Any clock constants you define for the purpose will be superceded by the top level program when the object is not, itself, the top level.

    -Phil
Sign In or Register to comment.