BASIC Stamp Architecture – Order of Operations
Page 60
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
On the BS2, BS2e, BS2sx and BS2p, not all of the math or logic operations
in a program are solved by the BASIC Stamp. The editor software solves
operations that define constants before the program is downloaded to the
BASIC Stamp. The preprocessing that takes place before the program is
downloaded is referred to as “compile time.”
After the download is complete, the BASIC Stamp starts executing your
program; this is referred to as “runtime.” At runtime the BASIC Stamp
processes math and logic operations involving variables, or any
combination of variables and constants.
Because compile-time and runtime expressions appear similar, it can be
hard to tell them apart. A few examples will help:
Result VAR BYTE 'Compile time assignment
Cheers CON 3 ' Compile time.
Glasses CON Cheers * 2 - 1 ' Compile time.
OneNinety CON 100 + 90 ' Compile time.
NoWorkee CON 3 * Result ' ERROR: Variables not allowed here
Result = Glasses ' Runtime.
Result = 99 + Glasses ' Runtime.
Result = One 1 ' "100 + 90" solved at compile-time,
' One 1 solved at runtime.
Result = 100 + 90 ' 100 + 90 solved at runtime.
Notice that the last example is solved at runtime, even though the math
performed could have been solved at compile time since it involves two
constants. If you find something like this in your own programs, you can
save some EEPROM space by converting the run-time expression 100+90
into a compile-time expression like OneNinety CON 100+90.
To sum up: compile-time expressions are those that involve only
constants; once a variable is involved, the expression must be solved at
runtime. That’s why the line “NoWorkee CON 3 * Result” would
generate an error message. The CON directive works only at compile time,
so variables are not allowed.
Let’s talk about the basic four operations of arithmetic: addition (+),
subtraction (-), multiplication (*), and division (/).
2
e
2
sx
2
p
2
2
e
2
sx
2
p
2
1
2
e
2
sx
2
p
2
W
HEN IS
R
UNTIME
?
O
RDER OF
O
PERATIONS
.
Содержание 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...