4: BASIC Stamp Architecture – Defining Variables
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 49
byte). Unlike I/O variables, there’s no reason that your program variables
have to be stuck in a specific position in the BASIC Stamp’s physical
memory. A byte is a byte regardless of its location. And if a program uses
a mixture of variables of different sizes, it can be a pain in the neck to
logically 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! The fixed variable names (of the general-
purpose variables) are only provided for power users who require
absolute access to a specific location in RAM.
We recommend that you avoid using the fixed variables in most
situations. Instead, let PBASIC allocate variables as described in the next
section. The editor software will organize your storage requirements to
make optimal use of the available memory.
Before you can use a variable in a PBASIC program you must declare it.
“Declare” means letting the BASIC Stamp know that you plan to use a
variable, what you want to call it, and how big it is. Although PBASIC
does have predefined variables that you can use without declaring them
first (see previous sections), the preferred way to set up variables is to use
the directive SYMBOL (for the BS1) or VAR (for all other BASIC Stamps).
Here is the syntax for a variable declaration:
SYMBOL Name = RegisterName
-- OR --
Name VAR Size
where Name is the name by which you will refer to the variable,
RegisterName is the "fixed" name for the register and Size indicates the
number of bits of storage for the variable. NOTE: The top example is for
the BS1 and the bottom example is for all other BASIC Stamps.
There are certain rules regarding symbol names. Symbols must start with
a letter, can contain a mixture of letters, numbers, and underscore (_)
characters, and must not be the same as PBASIC keywords or labels used
in your program. Additionally, symbols can be up to 32 characters long.
1
2
e
2
sx
2
p
2
1
2
e
2
sx
2
p
2
D
EFINING AND
U
SING
V
ARIABLES
.
T
HE
R
ULES OF
S
YMBOL
N
AMES
.
Содержание BASIC Stamp 1
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...