Specifications

BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 217
2
Using the names listed above, you can access any piece of any I/O
variables. And as we’ll see in the next section, you can use modifiers to
access any piece of any variable.
Predefined “Fixed” Variables
As table M-1 shows, the BS2’s memory is organized into 16 words of
16 bits each. The first three words are used for I/O. The remaining 13
words are available for use as general purpose variables.
Just like the I/O variables, the user variables have predefined names:
W0 through W12 and B0 through B25. B0 is the low byte of W0; B1 is
the high byte of W0; and so on through W12 (B24=low byte, B25=high
byte).
Unlike I/O variables, there’s no reason that your program variables
have to be stuck in a specific position in the Stamp’s physical memory.
A byte is a byte regardless of its location. And if a program uses a mix-
ture of variables of different sizes, it can be a pain in the neck to logi-
cally dole them out or allocate storage.
More importantly, mixing fixed variables with automatically allocated
variables (discussed in the next section) is an invitation to bugs. A fixed
variable can overlap an allocated variable, causing data meant for one
variable to show up in another!
We recommend that you avoid using the fixed variables in most situa-
tions. Instead, let PBASIC2 allocate variables as described in the next
section. The host software will organize your storage requirements to
make optimal use of the available memory.
Why have fixed variables at all? First, for a measure of compatibility
with the BS1, which has only fixed variables. Second, for power users
who may dream up some clever hack that requires the use of fixed
variables. You never know...
Defining and Using Variables
Before you can use a variable in a PBASIC2 program you must declare
it. “Declare” is jargon for letting the Stamp know that you plan to use
a variable, what you want to call it, and how big it is. Although PBASIC