You are not logged in.
Pages: 1
http://en.wikipedia.org/wiki/Endianness … _in_memory
In the section "Byte addresses increasing from right to left", does the XRAY example make sense to anyone? In my opinion the "<- increasing addresses" arrow is pointed the wrong way.
.:edit:.
Well, the arrow is pointing the right way (because that is the point of the example) but then the order of the characters is totally backwards...
Last edited by dtw (2011-05-27 14:42:29)
Offline
Nah, it makes sense. Characters are considered 8-bit values, so they fit inside a single byte, and hence aren't affected by endianness. The string "XRAY", which is the 8-bit values {'X','R','A','Y'} are stored in increasing 8-bit memory locations. Endianness comes into play when the value you're writing is larger than one byte.
For example, to extend their little-endian example, if you were storing two 32-bit integers X=int1=0A0B0C0D and R=int2=1A1B1C1D sequentially in memory (ie int1 followed by int2), each 32-bit value would show up in memory the same way the 8-bit characters of "XRAY" would, as:
increasing addresses ---->
------------------------------------------
| 0D | 0C | 0B | 0A | 1D | 1C | 1B | 1A |
------------------------------------------
|........int1.......|.........int2.......|
|..........X........|...........R........|
or
<---- increasing addresses
------------------------------------------
| 1A | 1B | 1C | 1D | 0A | 0B | 0C | 0D |
------------------------------------------
|........int2.......|.........int1.......|
|..........R........|...........X........|
Hopefully that's clear - it's hard to word
Last edited by Cerebral (2011-05-27 15:50:33)
Offline
I don't get the 16-bit part:
0A | 0B | 0C | 0D
gets transformed into
0A 0B | 0C 0D
- the order of bytes didn't change but instead of
Y | A | R | X
we get
A | Y | X | R
Is it because of the "16-bit atomic element notation"? So why isn't it
A Y | X R
?
Offline
Presuming you’re talking about the little endian, addresses increasing from right to left section. Does the floating table at the top right of the article make more sense?
0A 0B | 0C 0D
- the order of bytes didn't change
Firstly, if you’re talking 16-bit atomic memory words then the order of bytes doesn’t have any meaning, just the same as the order of the bits in those words or bytes isn’t relevant. I would have written it 0x0A0B | 0x0C0D with no spaces in the values.
So why isn't it
A Y | X R
I think it should be. I changed the last section on Wikipedia, what do you think of it now?
Endianness#Byte addresses increasing from right to left
For 16-bit words, the question is how do you store the characters. You could do one character per word, which would look just like the character-per-byte RTL visual. If you squeezed two characters (8 bits each) into a 16-bit word, I would probably represent it just as you did, where “X R” for a memory word means the first character is X and the second is R.
Maybe the person who put four memory cells was slipping back into 8-bit memory byte mode. For example if you encoded ASCII “XR” (X → 0x58, R → 0x52) as a 16-bit little endian word you’d get 0x5258; maybe they split the 0x5258 up into 8-bit bytes in their head.
Offline
Presuming you’re talking about the little endian, addresses increasing from right to left section. Does the floating table at the top right of the article make more sense?
karol wrote:0A 0B | 0C 0D
- the order of bytes didn't change
Firstly, if you’re talking 16-bit atomic memory words then the order of bytes doesn’t have any meaning, just the same as the order of the bits in those words or bytes isn’t relevant. I would have written it 0x0A0B | 0x0C0D with no spaces in the values.
Oh yes, that's even better.
karol wrote:So why isn't it
A Y | X R
I think it should be. I changed the last section on Wikipedia, what do you think of it now?
Endianness#Byte addresses increasing from right to left
It makes more sense to me.
Offline
Thanks for the responses.
I understood the concept but I didn't understand the example. Now I understand why: because it isn't an example at all, it's a caveat masquerading as an example.
So, what that section is saying is that writing right to left can make understanding little endian memory addressing more "human readable" but you should be aware that using that type of notation for memory addressing will make strings look "backwards" since chars occupy a whole byte and are thus unaffected by endianess?
Is that right?
Offline
Yep, exactly right
Offline
Pages: 1