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.
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:
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
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?
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
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?
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
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.
Comments
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
' {$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
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?
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
"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.
"geneitic programming" sounds interesting.
could you recommend a resource for learning more, a book would be fine fine.
rox on
nick B