/* Mainly view the Memory Distribution
· In a microprocessor, data such as long/DWORD (32bit) 0x12345678 is always stored in the big endian mode.
· However, in the memory, the data storage sequence varies depending on the microprocessor vendor.
One order is called Big-Endian, that is, putting the highest byte at the beginning; the other order is called Little-Endian, that is, putting the second byte at the beginning.
Address direction:
From low address to high address
Read direction:
The read direction is from high to low.
The memory on your computer (little endian) is arranged as follows:
01 00 00 00 0a 00 00 00 80 00 00 00 01 00 00
|
|__ I [0] ___ | |__ I [1] ___ | ___ I [2] __| |__ I [3] ___ |
If big endian is used, the memory is arranged as follows: // It is actually the same as that of the microprocessor.
00 00 00 01 00 00 00 0a 00 00 00 80 00 00 01 00
|
|__ I [0] ___ | |__ I [1] ___ | ___ I [2] __| |__ I [3] ___ |
I [0] = 00000000 00000000 00000000 00000001 // the order in the processor: Always big endian.
High Level ------------> low level
/// Little endian before low ./////
In the memory, it is represented as 10 00 00 in hexadecimal format.
/// Big endian is in the front position //////
In the memory, the hexadecimal format is 00 00 01;
Read/write memory content is always read from high to low. That is, 00 00 01;
*/
# Include <stdio. h>
Main ()
{
Int I [] = {128,256 };
For (Int J = 0; j <sizeof (I)/sizeof (I [0]); j ++)
{
Printf ("I = % # x/T", I [J]);
Printf ("I = % # X", & I [J]);
Printf ("/N ");
}
Return 0;
}
//////////////////////////////////////// //////////////////////////////////////// ///
Ru
Int ivals = 98341;
Hexadecimal: 18025
Small-end memory arrangement:
25 80 01 00
|
|__ Ival ___ |
Read:
00 01 80 25