View Single Post
  #11   Spotlight this post!  
Unread 02-12-2002, 01:55
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Re: Re: A couple of noodle scratchers

Quote:
Originally posted by Jnadke


One way to get around this is by loading the program into "slots". Read the manual for more details, but basically each slot has its own 26 bytes available to it. However, the data is not carried over from each slot.

Scratchpad RAM, however, is carried over.
Actually, the data is carried over between slots and all eight share a common 26 bytes of memory. The key is just making sure your variables "line-up" the same between slots. For example, if you have a byte variable named "myByte," you need to make sure it is in the same location in all slots if you want to access it in multiple programs.

The easiest way to do this is explicitly tell the PBASIC compiler where to put each variable. This can be done by making all variables "aliases" to the built-in, primitive ones (named b0-b25 and w0-w13). Note that these names do overlap. B0 and B1 are the two bytes of w0, b2 and b3 are the parts of w1, etc.

So far, I haven't seen a single program that was broken into multiple slots that couldn't have been done in a single slot. In fact, the only real advantage I see is that it could let you store different programs for different configurations (if your bot was modular), but even that can be done with a few well-placed "if" statements.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php