Shop OBEX P1 Docs P2 Docs Learn Events
Multiple programs? — Parallax Forums

Multiple programs?

Velvet LeopardVelvet Leopard Posts: 47
edited 2004-08-27 16:31 in BASIC Stamp
Hewwo, all.· I have been getting a bit better at my stamp programming.· Can you have more than one program on the stamp at one time?· Or just one?· I am just wondering.

Comments

  • cabojoecabojoe Posts: 72
    edited 2004-08-25 05:18
    You can run more than one program on the BS2E,BS2SX,BS2PE, andthe BS2P. Check out the RUN command syntax in the editor help file for more info.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-25 11:15
    To expand on CaboJoe's note, the BS2e and higher have multiple program slots (each 2K) and an area of RAM called the Scratchpad that can be used as a mechanism for transfering information between programs.· This article discusses the use of multiple program slots:

    http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv87.pdf

    If you're using a stock BS2, and your programs will fit in the EE space, you can use variable aliasing (using different names for the same RAM space) -- though technically one program, the behavior will be as if two programs are available in the same slot.· Just be a little careful, though, when you switch from one program to the other.· You may want o deliberately reinitialize the variables so that information left over from the other program doesn't interfere with the one that is about to run.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • poguemomhoinpoguemomhoin Posts: 13
    edited 2004-08-25 13:01
    I've just read through the NV89 column, but I'm confused as to how these programs are downloaded to the stamp. If I try to send the second listing (the external code), won't it just overwrite the first?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-25 13:16
    No, if you look at the mult-slot listings carefully you'll find that the slot zero program controls the loading of other slots. In the slot zero program, you'll have something that looks like this:

    ' {$STAMP BS2e, SLOT1.BSE, SLOT2.BSE}

    In this case, the program called SLOT1.BSE will be loaded into slot 1, and SLOT2.BSE will be loaded into slot 2. If you're using the latest compiler (suggested) you can find a description and notes of this use of the $STAMP directive in the Compiler Directives section. And yes, it's in the manual too (section 3).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • poguemomhoinpoguemomhoin Posts: 13
    edited 2004-08-25 13:34
    Got it, thanks.
    Here's a thought:
    Could I use this multiple program technique to update (overwite) one of the program slots with an update to a remote stamp?
    eg a stamp connected by modem, one of the subroutines could write bytes received directly into a slot, byte by byte?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-25 13:56
    I think you could pull that off with a BS2p or BS2pe, but not with the others. The reason is that the BS2p/pe allow READ and WRITE to work across program slots. You could, then, use one slot to receive data (program image) then write it to another slot. Obviously, you can't overwrite the current slot otherwise you would destroy your loader in the process.

    I believe that Scott Edwards did some experimenting with self-changing programs way back when, but as I remember the experiments were somewhat limited in scope and may not apply to what you want to do.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • J. A. StreichJ. A. Streich Posts: 158
    edited 2004-08-26 23:27
    Hmmmm....
    "self-changing programs"

    Sorta like genetic programming.... Only on a really small scale. Would sorta be cool to write a maze solver that uses genetic programming, but I've got too much on my plate at the moment as it is.
  • nick bernardnick bernard Posts: 329
    edited 2004-08-27 16:31
    there's always room for jello...

    "geneitic programming" sounds interesting.
    could you recommend a resource for learning more, a book would be fine fine.

    rox on
    nick B
Sign In or Register to comment.