5: BASIC Stamp Command Reference - DATA
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 95
Result VAR WORD
DATA word 1125
READ 0, Result.LOWBYTE
READ 1, Result.HIGHBYTE
DEBUG DEC 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
READ commands will read the low-byte and high-byte out of EEPROM
(reconstructing it in a word-size variable) and then display the value on
the screen. See the READ and WRITE commands for more information.
Demo Program (DATA.bs2)
This program stores a number of large text strings into EEPROM with the DATA directive and
then sends them, one character at a time via the DEBUG command. This is a good
demonstration of how to save program space by storing large amounts of data in EEPROM
directly, rather than embedding the data into DEBUG commands.
'{$STAMP BS2} ‘STAMP directive (specifies a BS2)
'-----Define variables-----
Index VAR WORD 'Holds current location number
PhraseNum VAR NIB 'Holds current phrase number
Character VAR BYTE 'Holds current character to print
'-----Define all text phrases (out of order, just for fun!)-----
Text1 DATA "Here is the first part of a large chunk of textual data", CR
DATA "that needs to be transmitted. There's a 12 second delay", CR
DATA "between text paragraphs.", CR, 255
Text3 DATA "The alternative (having multiple DEBUGs or SEROUTs, each", CR
DATA "with their own line of text) consumes MUCH more EEPROM", CR
DATA "(program) space; up to 854 more bytes, in this case!", CR, CR, 255
Text6 DATA "The 255 is used by this program to indicate we've reached the", CR
DATA "End of Text. The Main routine pauses in between each block of", CR
DATA "text, and then uses a LOOKUP command to retrieve the location", CR
DATA "of the next desired block of text to print.", 255
Text4 DATA CLS, "This program also demonstrates retrieving data out of order", CR
DATA "in relation to the way it is stored in EEPROM. Additionally", CR
DATA "control codes (like carriage-returns, clear-screens, etc) can", CR
DATA "be embedded right in the data, as it is here.", CR, CR, 255
Text2 DATA "This is an example of a good way to save space in your", CR
DATA "BASIC Stamp's program by storing data into EEPROM and", CR
DATA "retrieving it, one byte at a time, and transmitting it", CR
DATA "with just a single DEBUG (or SEROUT) command.", CR, CR, 255
Text5 DATA "The PrintIt routine simply takes the Index variable, retrieves", CR
NOTE: This is written for the BS2
but can be used for the BS2e,
BS2sx and BS2p also. Locate the
proper source code file or modify
the STAMP directive before
downloading to the BS2e, BS2sx or
BS2p.
2
e
2
sx
2
p
2
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...