Constants And Compile Time Expressions - Parallax BASIC Stamp 2e Programming Manual

Table of Contents

Advertisement

BASIC Stamp Architecture – Constants and Expressions
The BS2e, BS2sx and BS2p have some additional RAM called Scratch Pad
RAM. The BS2e and BS2sx have are 64 bytes of Scratch Pad RAM (0 – 63)
and the BS2p has 128 bytes of Scratch Pad RAM (0 – 127). Scratch Pad
RAM can only be accessed with the GET and PUT commands (see the GET
and PUT command descriptions for more information) and cannot have
variable names assigned to it.
The highest location in Scratch Pad RAM (location 63 on the BS2e and
BS2sx, location 127 on the BS2p) is read-only, and always contains the
number of the currently running program slot. This can be handy for
programs that need to know which program slot they exist in.
Suppose you're working on a program called "Three Cheers" that flashes
LEDs, makes hooting sounds, and activates a motor that crashes cymbals
together, all in sets of three. A portion of your PBASIC program might
contain something like:
FOR Counter = 1 TO 3
GOSUB MakeCheers
NEXT
...
FOR Counter = 1 TO 3
GOSUB BlinkLEDs
NEXT
...
FOR Counter = 1 TO 3
GOSUB CrashCymbals
NEXT
The numbers 1 and 3 in the code above are called constants. They are
constants because, while the program is running, nothing can happen to
change those numbers. This distinguishes constants from variables, which
can change while the program is running.
PBASIC allows you to use several numbering systems. By default, it
assumes that numbers are in decimal (base 10), our everyday system of
numbers. But you can also use binary and hexadecimal (hex) numbers by
identifying them with prefixes. And PBASIC will automatically convert
quoted text into the corresponding ASCII code(s). For example:
99
decimal
%1010
binary
$FE
hex
"A"
ASCII code for A (65)
Page 56 • BASIC Stamp Programming Manual 2.0b • www.parallaxinc.com
2
2
2
e
sx
p
S
P
RAM.
CRATCH
AD
C
C
-
ONSTANTS AND
OMPILE
TIME
E
.
XPRESSIONS
2
2
2
1
2
e
p
sx
2
2
2
1
2
e
sx
p

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents