BASIC stamp manual v2.2

5: BASIC Stamp Command Reference – EEPROM
BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com Page 185
EEPROM directive, and PBASIC will understand it to mean a series of
bytes (see the last line of code below). The following three EEPROM
directives are equivalent:
EEPROM (72, 69, 76, 76, 79)
EEPROM ("H", "E", "L", "L", "O")
EEPROM ("HELLO")
All three lines of code, above, will result in the numbers 72, 69, 76, 76, and
79 being stored into EEPROM upon downloading. These numbers are
simply the ASCII character codes for "H", "E", "L", "L", and "O",
respectively. See the demo program, below, for an example of storing and
reading multiple text strings.
The EEPROM is organized as a sequential set of byte-sized memory
locations. The EEPROM directive only stores bytes into EEPROM. If you
try to store a word-sized value, for example: EEPROM (1125), only the
lower byte of the value will be stored (in this case, 101). This does not
mean that you can't store word-sized values, however. A word consists of
two bytes, called a low-byte and a high-byte. If you wanted to store the
value 1125 using the EEPROM directive you'll have to calculate the low-
byte and the high-byte and insert them in the list in the proper order, as in:
EEPROM (101, 4)
The directive above will store the two bytes into two sequential EEPROM
locations (the low-byte first, followed by the high-byte). We calculated
this in the following manner: 1) high-byte is INT(value / 256) and 2) low-
byte is value – (high-byte * 256).
To retrieve a word-sized value, you'll need to use two READ commands
and a word-sized variable. For example,
SYMBOL result = W0 ' word-sized variable
SYMBOL resultLo = B0 ' B0 is the low-byte of W0
SYMBOL resultHi = B1 ' B1 is the high-byte of W0
EEPROM (101, 4)
READ 0, resultLo
READ 1, resultHi
DEBUG #result
This code would write the low-byte and high-byte of the number 1125 into
locations 0 and 1 during download. When the program runs, the two
WRITING WORD VALUES VS. BYTE VALUES.