Specifications

BASIC Stamp II
Page 228 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
BS2 EEPROM Data Storage
When you press ALT-R (run), your program is loaded into the BS2’s
EEPROM starting at the highest address (2047) and working down-
ward. Most programs don’t use the entire EEPROM, so PBASIC2 lets
you store data in the unused lower portion of the EEPROM.
Since programs are stored from the top of memory downward, your
data is stored in the bottom of memory working upward. If there’s an
overlap, the Stamp host software will detect it and display an error
message.
Data directives are used to store data in EEPROM, or to assign a name
to an unused stretch of EEPROM (more on that later). For example:
table data 72,69,76,76,79
That data directive places a series of numbers into EEPROM memory
starting at address 0, like so:
Address: 01 23 4
Contents: 72 69 76 76 79
Data uses a counter, called a pointer, to keep track of available EEPROM
addresses. The value of the pointer is initially 0. When PBASIC2 en-
counters a Data directive, it stores a byte at the current pointer ad-
dress, then increments (adds 1 to) the pointer. The name that Data as-
signs (table in the example above) becomes a constant that is equal to
the first value of the pointer; the address of the first of the series of
bytes stored by that Data directive. Since the data above starts at 0, the
constant table equals 0.
If your program contains more than one Data directive, subsequent
Datas start with the pointer value left by the previous Data. For ex-
ample, if your program contains:
table1 data 72,69,76,76,79
table2 data 104,101,108,108,111