Shop OBEX P1 Docs P2 Docs Learn Events
bit''s from slot to slot — Parallax Forums

bit''s from slot to slot

ArchiverArchiver Posts: 46,084
edited 2002-02-08 17:27 in General Discussion
>So if I declare all variables EXACTLY the same in each page, I dont need to
>use the put/get tools ?

Yes, if you declare the variables exactly the same in each page, then
you can access them from each page.

It helps to understand exactly how the Stamp allocates the 26 bytes
of RAM. That can be words, bytes, nibs or bits, or any mixture of
the two. The Stamp allocates space for all the words first, in the
order you define them in your program, following the words in RAM it
allocates space for all the bytes in your program, again in the order
they appear in your definitions. Then come the nibs and then the
bits. And within each group, the space is allocated in the order you
define them in your program. Heinz' example has one bit and one
byte. The Stamp allocates the byte, "testloop" slot 1 out of 26 in
RAM, and then the bit, "flag", goes in what would be bit0 of the next
byte in memory. (That is bit 9 out of 208 possible in RAM.) Done in
both bank 0 and bank 1, the program runs fine. When he defines one
more bit, "flagxy" it now takes over that bit0 slot and "flag" moves
up to the bit1 slot in the second byte in memory. Since he defined
"flagxy" only in bank 0, that caused a problem, because flag occupies
the 9th bit slot in bank 0 and the 10th bit slot in bank 1. If he
were to define the bits in the opposite order, "flag" and then
"flagxy" the problem would not occur, because flag would occupy the
9th slot in both banks.

The Stamp manual has a good explanation about how the variables are
allocated in RAM.

If you use alias names for variables, that does not change the order
of allocation. It just makes new pointers to the existing
allocations.

There are several ways to deal with the issue, depending on the
complexity of the program. (1) aligning the variables in the
different banks; (2) systematic use of aliases to collapse all of the
"global" variables into words (so they will appear first in RAM); (3)
ad-hoc or systematic use of the scratchpad RAM as temporary storage
or as a "stack"; (4) Use of only the preassigned variable names, b0
to b25.

The BS2P at least makes one thing a lot simpler. That is the STORE
command, which combined with READ and WRITE allows you to move data
from one bank to another without actually RUNning the other bank.

I have some of my app-notes on using the multibank stamps posted at
http://www.emesystems.com/BS2SX.htm

-- regards,
Tracy Allen
electronically monitored ecosystems
mailto:tracy@e...
http://www.emesystems.com



>Jon,
>So if I declare all variables EXACTLY the same in each page, I dont need to
>use the put/get tools ?
>
>Rgds,
>Chris
>
>
Original Message
>From: <jonwms@a...>
>To: <basicstamps@yahoogroups.com>
>Sent: Friday, February 08, 2002 10:06 PM
>Subject: Re: [noparse][[/noparse]basicstamps] bit's from slot to slot
>
>
> > In order for this to work you must define the variables in one program
>(slot)
> > EXACTLY as and _in_the_same_order_ as in your other program (slot). The
> > other thing you can do is use PUT and GET with the shared scratchpad
>memory.
> >
> > -- Jon Williams
> > -- Parallax
> >
> >
> > In a message dated 2/8/02 7:41:35 AM Central Standard Time,
> > hschwenk@y... writes:
> >
> >
> > > Hi all,
> > > > I use Stamp2P 40
> > > > My programs did not work together in the different
> > > program slots.......
> > > > reducing the code step by step to:
> > > > In slot 0:
> > > > ************************************
> > > > '{$STAMP BS2p,test1}
> > > > 'flagxy var bit
> > > > flag var bit
> > > > testloop var byte
> > > > flag=1
> > > > testloop=testloop+1
> > > > Debug "test= ",dec testloop," flag= ",dec flag,cr
> > > > pause 2000
> > > > run 1
> > > > ***************************************
> > > > In slot 1:
> > > > '{$STAMP BS2p}
> > > > flag var bit
> > > > testloop var byte
> > > > Debug "TEST1= ",dec testloop," flag= ",dec flag,cr
> > > > pause 2000
> > > > run 0
> > > > ******************************************
> > > > if the "flagxy var bit " is deactivated,
> > > > in my debug "TEST1" the flag=1 like I expected
> > > > But now:
> > > > if I activate flacxy var bit
> > > > in my debug "TEST1" the flag=0 I DID NOT ASPECT
> > > THIS
> > > > the "counting" of the "testloop" is always to see
> > > right
> > > >
> > > > Do I do or understand something wrong ?
> > > > Or is it not allowed to "transfer" Information from
> > > slot0 to the
> > > > slot1 via bit's?
> > > > Is there any documentation (which I did not see)?
> > > > Or is it a bug?
> > > >
> > > > some ideas or information's would be helpful
> > > > Thanks Heinz
> > >
> >
> >
> >
> >
> > [noparse][[/noparse]Non-text portions of this message have been removed]
> >
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@yahoogroups.com
> > from the same email address that you subscribed. Text in the Subject and
>Body of the message will be ignored.
> >
> >
> > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Sign In or Register to comment.