Data Memory Distribution

Source: Internet
Author: User

/* 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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.