BASIC Stamp Architecture – Constants and Expressions
Page 56
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
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)
C
ONSTANTS AND
C
OMPILE
-
TIME
E
XPRESSIONS
.
1
2
e
2
sx
2
p
2
1
2
e
2
sx
2
p
2
e
2
sx
2
p
2
S
CRATCH
P
AD
RAM.
Summary of Contents for BASIC Stamp 1
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...