[Embedded C] Understanding of big and small endian in computers

simply put

Big endian conforms to human habits

MSB LSB

In microcontrollers, we often see descriptions such as MSB first and LSB first.

Most Significant Bit, Last (Least) Significant Bit
High Significant Bit Low Significant Bit

For a1, the 1 placed in the hundreds place is larger and more 'valuable' than the 1 placed in the tens place, so we say it can represent greater The bits of data are 高有效位, and the smaller bits representing data are called 低有效位
. For example, the number 5 is 0101b in binary; then
Insert image description here

big endian little endian

big endian meanslower address stores the most significant byte (MSB),
little endian means YesThe low address stores the least significant byte (LSB).

Example 1, illustrated with figures using the number 0xB4 (10110100)

Insert image description here

Example 2 illustrates with int a =5;

Insert image description here
a is an int type data, occupying 4 bytes. Its address is 0x600 0001, but it is 大端, so it is stored at a low address (0x600 0001 relative to 0x600 0004) MSB (highly significant bit), so big endian

Guess you like

Origin blog.csdn.net/apythonlearner/article/details/132579674