BASIC stamp manual v2.2
DATA – BASIC Stamp Command Reference
Page 154 • BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com
DATA uses a counter, called a pointer, to keep track of available EEPROM
addresses. The value of the pointer is initially 0. When a program is
downloaded, the DATA directive stores the first byte value at the current
pointer address, then increments (adds 1 to) the pointer. If the program
contains more than one DATA directive, subsequent DATAs start with the
pointer value left by the previous DATA. For example, if the program
contains:
DATA 72, 69, 76, 76, 79
DATA 104, 101, 108, 108, 111
The first DATA directive will start at location 0 and increment the pointer
for each data value it stores (1, 2, 3, 4 and 5). The second DATA directive
will start with the pointer value of 5 and work upward from there. As a
result, the first 10 bytes of EEPROM will look like the following:
EEPROM Location (address)
0 1 2 3 4 5 6 7 8 9
Contents
72 69 76 76 79 104 101 108 108 111
Table 5.8: Example EEPROM
Storage.
What if you don’t want to store values starting at location 0? Fortunately,
the DATA directive has an option to specify the next location to use. You
can specify the next location number (to set the pointer to) by inserting a
DataItem in the form @x ;where x is the location number. The following
code writes the same data in Table 5.8 to locations 100 through 109:
DATA @100, 72, 69, 76, 76, 79, 104, 101, 108, 108, 111
In this example, the first DataItem is @100. This tells the DATA directive to
store the following DataItem(s) starting at location 100. All the DataItems to
the right of the @100 are stored in their respective locations (100, 101,
102… 109).
In addition, the DATA directive allows you to specify new starting
locations at any time within the DataItem list. If, for example, you wanted
to store 56 at location 100 and 47 at location 150 (while leaving every other
location intact), you could type the following:
DATA @100, 56, @150, 47
If you have multiple DATA directives in your program, it may be difficult
to remember exactly what locations contain the desired data. For this
reason, the DATA directive can optionally be prefixed with a unique
THE DATA POINTER (COUNTER).
W
RITING DATA TO OTHER LOCATIONS.
A
UTOMATIC CONSTANTS FOR DEFINED
DATA
.