Specifications

BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 229
2
The first Data directive will start at 0 and increment the pointer: 1, 2, 3,
4, 5. The second Data directive will pick up the pointer value of 5 and
work upward from there. As a result, the first 10 bytes of EEPROM
will contain:
Address: 0123456789
Contents: 72 69 76 76 79 104 101 108 108 111
...and the constants table1 and table2 will be equal to 0 and 5, respec-
tively.
A common use for Data is to store strings; sequences of bytes repre-
senting text. As we saw earlier, PBASIC2 converts quoted text like “A”
into the corresponding ASCII character code (65 in this case). You can
place quotes around a whole chunk of text used in a Data directive,
and PBASIC2 will understand it to mean a series of bytes. The follow-
ing three Data directives are equivalent:
table1 data 72,69,76,76,79
table2 data “H”,”E”,”L”,”L”,”O”
table3 data “HELLO”
Data can also break word-sized (16-bit) variables into bytes for storage
in the EEPROM. Just precede the 16-bit value with the prefix “word”
as follows:
twoPiece data word $F562 ‘ Put $62 in low byte, $F5 in high.
Moving the Data Pointer
You can specify a pointer address in your Data directive, like so:
greet data @32,”Hello there”
The number following the at sign (@) becomes the initial pointer value,
regardless of the pointer’s previous value. Data still automatically in-
crements the pointer value as in previous examples, so Data directives
that follow the example above will start at address 43.
Another way to move the pointer is to tell Data to set aside space for a
particular number of bytes. For example: