PBASIC question about DATA directive
connolly113
Posts: 8
I have a question about the DATA directive·in the pbasic syntax guide, one of the examples given is pasted below. I cannot figure
out where the "101" and "4" come from, can someone explain this to me
thks.
(BS2pe,PBASIC 2.5)
DATA········· Word 1125
The directive above will automatically break the
word-size value into two bytes and store them into two
sequential EEPROM locations (the low-byte first,
followed by the high-byte, or "Little Endian"). In
this case, the low-byte is 101 and the high byte is 4
and they will be stored in locations 0 and 1, respectively.
out where the "101" and "4" come from, can someone explain this to me
thks.
(BS2pe,PBASIC 2.5)
DATA········· Word 1125
The directive above will automatically break the
word-size value into two bytes and store them into two
sequential EEPROM locations (the low-byte first,
followed by the high-byte, or "Little Endian"). In
this case, the low-byte is 101 and the high byte is 4
and they will be stored in locations 0 and 1, respectively.
Comments
1125 (decimal)=0000010001100101 (binary)
101 (decimal)=01100101 (binary)
4 (decimal)=00000100 (binary)
so, if you stick them together, you get 00000100 01100101 which is 1125 in decimal.
its like reading the two bytes that make the word independently.
I hope I helped some!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There are 10 kinds of people in the world;
those who understand binary and those who don't.
That gets broken up into two bytes.
The MSB gets stored in·an address as·% 0000 0100···(4)
The LSB gets stored in an address as % 0110 0101·(101)
(4 x 256) + (1·x 101) = 1125
·········· 1024 + 101 = 1125
················ 1125 = 1125