BASIC Stamp Architecture – Defining Variables
Page 50
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
See Appendix B for a list of PBASIC keywords. PBASIC does not
distinguish between upper and lower case, so the names MYVARIABLE,
myVariable, and MyVaRiAbLe are all equivalent.
For the BS1, the RegisterName is one of the predefined "fixed" variable
names, such as W0, W1, B0, B1, etc. Here are a few examples of variable
declarations on the BS1:
SYMBOL Temporary = W0 ' value can be 0 to 65535
SYMBOL Counter = B1 ' value can be 0 to 255
SYMBOL Result = B2 ' value can be 0 to 255
The above example will create a variable called Temporary whose contents
will be stored in the RAM location called W0. Also, the variable Counter
will be located at RAM location B1 and Result at location B2. Temporary is
a word-sized variable (because that's what size W0 is) while the other two
are both byte-sized variables. Throughout the rest of the program, we can
use the names Temporary, Counter, and Result instead of W0, B1 and B2,
respectively. This makes the code much more readable; it's easier to
determine what Counter is used for than it would be to figure out what the
name B1 means. Please note, that Counter resides at location B1, and B1
happens to be the high byte of W0. This means than changing Counter will
also change Temporary since they overlap. A situation like this usually is a
mistake and results in strange behavior, but is also a powerful feature if
used carefully.
For the BS2, BS2e, BS2sx and BS2p, the Size argument has four choices: 1)
BIT (1 bit), 2) NIB (nibble; 4 bits), 3) BYTE (8 bits), and 4) WORD (16 bits).
Here are some examples of variable declarations on the BS2, BS2e, BS2sx
or BS2p:
Mouse VAR BIT ' Value can be 0 or 1.
Cat VAR NIB ' Value can be 0 to 15.
Dog VAR BYTE ' Value can be 0 to 255.
Rhino VAR WORD ' Value can be 0 to 65535.
1
1
2
e
2
sx
2
p
2
2
e
2
sx
2
p
2
Содержание BASIC Stamp 2e
Страница 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...