Data storage size-end Mode

Source: Internet
Author: User

The so-called Big-end mode stores the index data low (that is, the few digits after the smaller weights) in the memory's high address, while the data is high, stored in a low address in the memory, this storage mode is a bit similar to processing data as a string Order: The address increases from small to large, and the data is placed from high to low;

The so-called small-end mode stores low data points in the low memory address, while the high data points are stored in the high memory address, this storage mode effectively combines the high and low addresses with the data bit permissions. The high address part has a high weight, and the low address part has a low weight, which is consistent with our logic method.

Why are there differences in the size mode? This is because in computer systems, we use bytes. Each address unit corresponds to one byte, and each byte is 8 bit. However, in C language, apart from 8-bit char, there are 16-bit short and 32-bit long (depending on the specific compiler). In addition, for a processor whose digits are greater than 8 bits, for example, for a 16-bit or 32-bit processor, because the register width is greater than one byte, there must be a problem if multiple bytes are arranged. Therefore, the large-end storage mode and the Small-end storage mode are created. For example, if the address of a 16-bit short X in the memory is 0x0010 and the value of X is 0x1122, 0x11 is a high byte and 0x22 is a low byte. In the big-end mode, place 0x11 in the low address, that is, 0x0010, and 0x22 in the high address, that is, 0x0011. The small-end mode is the opposite. Our commonly used x86 structure is a small-end model, while Keil C51 is a large-end model. Many arm and DSP are in small-end mode. Some arm processors can also choose big-end mode or small-end mode from hardware. The following Code can be used to test whether your compiler is in the big-end mode or the small-end mode: Short int X; char x0, x1; X = 0x1122; X0 = (char *) & X) [0]; // low address unit X1 = (char *) & X) [1]; // if the high address unit is X0 = 0x11, it is a large end. If X0 = 0x22, it is a small end ...... the preceding Program shows that the address of the low byte is used for data addressing.

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: 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.