Bit/Byte adressing - Little/Big-endnian
Posted
by
code8230
on Stack Overflow
See other posts from Stack Overflow
or by code8230
Published on 2012-10-05T21:24:48Z
Indexed on
2012/10/05
21:37 UTC
Read the original article
Hit count: 173
c
Consider the 16-Bit data packet below, which is sent through the network in network byte order ie Big Endian:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (Byte num)
34 67 89 45 90 AB FF 23 65 37 56 C6 56 B7 00 00 (Value)
Lets say 8945 is a 16 bit value. All others are 8 bit data bytes.
On my system, which is little endian, how would the data be received and stored?
Lets say, we are configured to receive 8 bytes at a time. RxBuff is the Rx buffer where data will be received.
Buff is the storage buffer where data would be stored.
Please point out which case is correct for data storage after reading 8 bytes at a time: 1) Buff[] = {0x34, 0x67, 0x45, 0x89, 0x90, 0xAB....... 0x00};
2) Buff[] = {0x00, 0x00, .......0x67, 0x89, 0x45, 0x34};
Would the whole 16 bytes data be reversed or only the 2 bytes value contained in this packet?
© Stack Overflow or respective owner