|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Endianness |
|
|
|
|
Why is endianness
significant? |
|
|
|
If you transfer data
between machines (removable media or network), |
|
|
|
you need to know which
order it is stored in. |
|
|
Things to note: |
|
|
|
|
The order refers to
BYTES, not bits. The bits are not simply reversed from lsb to msb. |
|
|
Ordering only refers to
data stored in MEMORY. |
|
|
|
Data in registers stored
from msb to lsb, left to right, regardless of endianness. |
|
|
32-bit register:
b31....b0 |
|
|
|
|
|
Endianness has nothing
to do with the order of C-style strings. |
|
|
|
What is a C-style string? |
|
|
|
|
|
Array of char, ended by
'\0' |
|
|
|
|
Each char is 1 byte |
|
|
|
|
|
|
course |
C |
M |
S |
C |
|
3 |
1 |
1 |
\0 |
|
|
|
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
|
|
|
|
|
char course[]= "CMSC
311"; |
|
|
|
Arrays are always stored
from element 0 to element (n-1) |
|
|
|
Note that C++ style
strings are objects, may have more complicated structure |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|