Size-end mode and processor

Source: Internet
Author: User

I. History
The term endian is written by Jonathan Swift. This Book classifies all people into two categories based on the way they open the eggs. From the beginning, the people who open the eggs are classified as big endian, from the beginning, the person who opens the eggs is classified as littile endian. The civil war in the minor people's country stems from the fight between big-Endian and little-Endian when eating eggs. Big endian and little endian in the computer industry have also caused almost a war. In the computer industry, endian indicates the order in which data is stored in memory.
PowerPC processors dominate the network market. It can be said that most communication devices use PowerPC processors to process protocols and other control information, this may also be the reason why most of the protocols on the network adopt the large-end addressing method. Therefore, in software design related to network protocols, a small-End Processor needs to change the processing mode in the software. Pentium leads the man-machine market, so most of the peripherals used for man-machine use the small-end mode, including some PCI bus, flash and other devices used in network equipment, this also requires hardware engineers to pay attention to Terminal Mode Conversion in hardware design.

Ii. Use a processor of large and small terminals
The commonly used x86 structure is the small-end mode, while the c51 single-chip microcomputer is the large-end mode (eight-bit 51 does not have the size end, but the Keil C51 compiler is the large-end ). 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 iSCSI processor is a large-end processor.
The use of big-end data storage is in line with human normal thinking, while the use of small-end data storage is conducive to computer processing. So far, data has been stored on large or small ends, and its advantages and disadvantages are still unknown. Therefore, in a processor system, large and small ends may coexist. This phenomenon has brought a lot of trouble to the system's hardware and software design. This requires system design engineers to have a deep understanding of the differences between the big end and small end models. The differences between the big-end and small-end modes are reflected in the registers, instruction sets, system bus, and other layers of a processor.

Iii. Big-end and small-end conversion method:
Convert big-Endian to little-endian as follows:
# Define bigtolittle16 (A) (uint16) (a) & 0xff00)> 8) |
(Uint16) (a) & 0x00ff) <8 ))
# Define bigtolittle32 (A) (uint32) (a) & 0xff000000)> 24) |
(Uint32) (a) & 0x00ff0000)> 8) |
(Uint32) (a) & 0x0000ff00) <8) |
(Uint32) (a) & 0x000000ff) <24 ))

Iv. Large-end and small-end detection methods:
How do I check whether the processor is big-Endian or little-Endian?
The storage order of union Union is that all members are stored from the low address. With this feature, the CPU can easily read and write the memory in the little-Endian or big-Endian mode.
Int checkcpuendian ()
{
Union
{
Unsigned int;
Unsigned char B;
} C;
C. A = 1;
Return (C. B = 1 );
}
/* Return 1: Little-Endian, return 0: Big-Endian */

Refer:

Http://blog.csdn.net/wkhd2008/article/details/6543269

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.