BASIC stamp manual v2.2

BASIC Stamp Architecture – Number Representations
Page 98 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
and the last nibble is 6; this corresponds exactly to the BCD form of the
decimal number 4096. The second line in the above example uses the HEX
Conversion Formatter within the DEBUG command (see DEBUG, page
159) to output the BCD value 4096 to the Debug Terminal. The HEX
Conversion Formatter can also be used for input operations to convert a
decimal value to BCD, as long as that decimal value is no greater than 2
digits for a Byte-sized variable or 4 digits for a Word-sized variable.
For more information on constants, see the section "Constants and
Compile-Time Expressions", above.
With all BS2 models, some 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 “run-time.” At run-time the BASIC Stamp
processes math and logic operations involving variables, or any
combination of variables and constants.
Because compile-time and run-time 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
NotWorking CON 3 * result ' ERROR: Variables not allowed here
result = Glasses ' Run-time
result = 99 + Glasses ' Run-time
result = OneNinety + 1 ' "100 + 90" solved at compile-time
' OneNinety + 1 solved at run-time
result = 100 + 90 ' 100 + 90 solved at run-time
Notice that the last example is solved at run-time, 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 program space in the EEPROM by converting the run-time
WHEN IS RUN-TIME?
All
2
All
2