Big endian and small end

Source: Internet
Author: User

Big-endian mode, called the big-endian mode (Big-endian), refers to the high-byte data, which is kept in the low-memory address, while the low-byte of the data is stored in the high-memory address, such that the storage mode is somewhat similar to the data as a string order: address from small to large increase, and data from high to low ; Example: 0000430:e684 6c4e 0100 1800 53ef 0100 0100 00000000440:b484 6c4e 004e ed00 0000 0000 0100 0000 In big-endian mode, the first 32 bits should read this: E6 8 4 6c 4e (assuming int is 4 bytes) Memory method: The growth order of addresses is the same as the growth order of the values. The so-called small-end mode (Little-endian) refers to the high byte of data stored in the high address of memory, while the low byte of data is kept in the low address of memory, This kind of storage mode combines the high and low value of the address with the right of the data bit, the higher the weight of the address part, the lower the weight value, and the same as our logical method. Example: 0000430:e684 6c4e 0100 1800 53ef 0100 0100 00000000440:b484 6c4e 004e ed00 0000 0000 0100 0000 In small-ended mode, the first 32 bits should read this: 4e 6c E6 (assuming int is 4 bytes) Memory Method: Address growth order and value growth order reverse size End pattern Why is there a size-end pattern? This is because in the computer system, we are in bytes, each address unit corresponds to a byte, one byte is 8bit. But in the C language in addition to 8bit of Char, there are 16bit short type, 32bit long (to see the specific compiler), in addition, for the number of bits greater than 8 bits of the processor, such as 16-bit or 32-bit processor, because the register width is greater than one byte, Then there must be a problem with how to arrange multiple bytes. The result is a big-endian storage mode and a small-end storage mode. For example, a 16bit short x, where the value of address 0x0010,x in memory is 0x1122, then 0x11 is a high byte and 0x22 is a low byte. For big-endian mode, put 0x11 in the low address, that is, 0x0010, 0x22 placed in the high address, that is, 0x0011. Small-end mode, just the opposite. The X86 structure we commonly use is the small-end mode, while the Keil C51 is the big-endian mode. Many of the arm,dsp are in the small-end mode. Some arm processors can also be used at any time in the program (Rev, REV16, revsh directives in the arm Cortex series [1]  ) to switch the size end. Illustrations for 0x11223344 storage are as follows  

Big-endian and small-end

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.