Syntax to word constants?

Peterf

New Member
The read command can take a word argument, e.g.
read 0,WORD w4

The manual says "When word variables are used (with the keyword WORD) the two bytes of the
word are saved/retrieved in a little endian manner (ie low byte at address, high
byte at address + 1)". Fine.

Now consider the converse problem: using the EEPROM command to load the memory with word data. It seems I cannot say something like
EEPROM 0,(1, 2, WORD 12345, 6, 7)

It's possible that if I said
EEPROM 0,(1, 2, 12345, 6, 7)
that Basic would compile the 12345 as two bytes. But then, if the word value I actually want to enter is less than 256, I'd have to remember to insert a 0 byte.
 

hippy

Technical Support
Staff member
EEPROM only places bytes into its data memory so it would only store the LSB of 12345. You can however do this -

Code:
Symbol N     = 12345

Symbol N.msb = N / 256
Symbol N.lsb = N & 255

Eeprom 0, ( N.lsb, N.msb )

Read 0, Word w0
SerTxd( #w0 )
 

lbenson

Senior Member
And of course for dynamic (under program control) loading of eeprom, the opposite of

read 0,WORD w4

is

write 0,WORD w4

I don't know of any intrinsic reason why the eeprom command could not be expanded to accept the WORD designation.
 
Last edited:

Peterf

New Member
Thanks. So there isn't a neat answer for statically declared EEPROM data, but one can use a symbol workaround to clarify things.
 
Top