Data storage mode: Big-end mode and small-end mode.

Source: Internet
Author: User

Data storage mode: Big-end mode and small-end mode.

CPU and data in different architectures are stored in different order in the memory.

The storage of data in memory is based on bytes. Therefore, Word and Half-Word are stored in two orders: big Endian and Little Endian ).

Small-end Storage refers to the storage of low data bytes at low memory addresses, and the storage of high data bytes includes high data bytes;

Large-end Storage refers to the storage of Low-byte data at the Internal High address, and the high-byte data is stored at the low-byte memory;

Typedef unsigned long u32; typedef unsigned short 2010; typedef unsigned char u8; int main (void) {u8 I; u32 data = 0x78563412; u8 * p = (u8 *) & data; for (I = 0; I <4; I ++) {printf ("% # x", p); printf ("% # x \ n ", * p); p ++;} return 0 ;} /*************************************** * ******** the output result in VC ++ 6.0 is: 0x18ff40 0x120x18ff41 0x340x18ff42 0x560x18ff43 0x78Press any key to continue ******************************* ******************/

Note the following:

(1) data is stored in large-end mode in registers.

(2) data stored in Small-end mode in memory. When CPU access is counted, the conversion between the small end and the big end is achieved through hardware, without the overhead of Data Loading/storage.

Related Article

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.