combining 2 8 bits data from eeprom into 16 bit data

moorea21

Senior Member
I have 16 bit addresses stored in 2 sequential eeprom addresses, and I want to combine them into a 16 bit word, to address a max7219 chip.

I thought there was a method that used 'highbyte' and 'lowbyte', but I can't find anything about it.

instead of combining the 2 bytes into a word, can I just pass them together as 2 variables to the max7219?

So b1 = 00001000, b2 = 01000001;
address would need to be 0000100001000001
so send (b1, b2) to max7219?

I'm sure I've done this before, but probably only once, and I seem to have deleted it from my HD.
 

hippy

Technical Support
Staff member
If you use the component byte variable parts of a word variable you will automatically create the word value by setting the byte variables; eg -

b1 = $AB
b0 = $CD

is the same as

w0 = $ABCD

You can symbol define byte variables to more obviously describe parts of the word ...

Symbol w0.lsb = b0
Symbol w0.msb = b1

w0.msb = $AB
w0.lsb = $CD

will also set w0 to $ABCD

You can similarly read two bytes of EPROM to effectively read a word variable, or just use 'READ adr, WORD wvar'.
 

moorea21

Senior Member
Okay, thanks both.

Yes, should have read the manual properly. Scanned it, didnt find the terms 'highbyte' or lowbyte' and then moved on...
 
Top