View Full Version : What memory is used for DATA @X, LONG $XXXXXX
svjohngalt
- 14th October 2017, 04:32
If one uses the DATA command to write to EEPROM at program time and are writing a LONG variable, how many bytes are used in memory and what locations are used. The memory is organized in bytes and writing DATA @0, $FF writes to the 1st byte of memory. If instead DATA @0, LONG $FFFFFFFF, does this write to eeprom locations 0,1,2 and 3 or is the memory managed by the PIC such that memory location 0 is a long and the next memory location is 1 which will also be a long?
Thanks
HenrikOlsson
- 14th October 2017, 08:18
If you write a LONG to EEPROM it will occupy 4 bytes or "locations". So if your LONG starts at 0 the next free byte/location will be at adress 4.
To be honest I'm not sure about the "order", ie little vs big endian but that's easy enough to test.
/Henrik.
sayzer
- 14th October 2017, 10:00
This should give you some idea how it is orginized.
It explains itself. I captured the values 4 times, and the picture shows all 4 values.
LongVal var long
ByteVal0 var byte
ByteVal1 var byte
ByteVal2 var byte
ByteVal3 var byte
Test:
'%00000000 00000000 00000000 00000001
'%00000000 00000000 00000001 00000000
'%00000000 00000001 00000000 00000000
'%00000001 00000000 00000000 00000000
longval = %00000000000000000000000000000001 '32-bit value.
write 0, long longval
read 0, byteval0
read 1, byteval1
read 2, byteval2
read 3, byteval3
lcdout $fe,1,"LongVal:", dec longval
lcdout $fe,$94,"10:",bin8 byteval1," ",bin8 byteval0
lcdout $fe,$D4,"32:",bin8 byteval3," ",bin8 byteval2
pause 100
goto test
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.