Variables and RUN statement
ScottL
Posts: 14
I am having a difficult time getting my head around page 382 in the syntax manual. I thought the only way to share variables was to GET and PUT them to scratch pad RAM. I understand that BS2 stores word length variables first but why can slot 1 see them if they are not passed? What am I missing? -Scott
Comments
GET and PUT provide another way to pass variables around, available on all of the multibank Stamps.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
·· You can also check out the following Nuts & Volts article on Multi-Bank Programming, which may prove insightful.· I hope this helps.· Take care.
http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv87.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
EXACTLY so! In fact, is often easisest to use the Stamp Editor's COPY and PASTE facility to ensure that all banks are the same. That's NOT to say if you had some compelling reason to do so, you couldn't then change the names of certain of the variables, if different names would make more sense in the "other" bank(s). The order and the size are the two important characteristics, as the variable names are not brought forward (internally) at all.
The following is just an advanced tip, so if you're new to PBASIC, it can be totally ignored. Others may find it interesting or useful.
In order to make the best use of RAM storage, the PBASIC Editor/Interpreter will always force the order of the variables (VAR statement) in allocated RAM memory according to SIZE. Thus, all WORD sized variables will be allocated in available RAM storage first, and before any BYTE sized variables. All Byte sized variables will be allocated storage before any NIB variables. And finally, all NIB sized variables will be allocated storage before any BIT sized variables. Just as an additional sidenote NO STORAGE is allocated for user defined CONSTANTS (CON statement).
So, when you look at the PBASIC Editor's Memory Map, the order you see will be the ACTUAL memory assignments, and they may NOT be in the order you have assigned them, unless you used the same rules for variable assignment.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
p.s.·I like the "Scotti" thang I may use it for an alias sometime! Computer alias that is. Why don't they have a "Dumb A**" emoticon? Once I comprehend something I marvel at how dense I was.
That is defined as one of the first words in every slot, along with other important pointers. Also there can be nib and byte size variables and pointers, and those can also be defined as aliases within the first few words in every bank.
The avantage of using alias names within words is that all the really important keeper variable can be concentrated at the top of memory in the primary allocation, and you can leave the rest of the words, bytes, nibs and bits free for local use within each individual slot without concern for order. If you just go and define a bit as a Bit, standalone, then as Bruce pointed out it will be allocated space after all the words, bytes and nibs, so then you are forced to align _all_ of the variables, keepers or not, instead of just the words. Be sure you get familiar with the alias name capabiltiy of the Stamp! The whole RAM memory is an array common to all the slots. Very powerful.
I make heavy use of the scratchpad and the eeprom. The RAM holds the pointers.
Another take on multibank programming is www.emesystems.com/BS2SX.htm.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com