It is useless to say more, and the people around me are dizzy. You can see the address:
Large byte order: Put the High Effective bit in the low address segment. For example, in the byte addressing memory, store the value 0x0001 to the address 0x12345678.
Address Value
0x0004 0x78
0x0003 0x56
0x0002 0x34
0x0001 0x12
Small byte order: Put the low valid bit in the low address segment. For example, in the byte addressing memory, store the value 0x0001 to the address 0x12345678.
Address Value
0x0004 0x12
0x0003 0x34
0x0002 0x56
0x0001 0x78
Currently, the mainstream CPU and Intel series use the little endian format to store data.
Determination Method:
Many languages have built-in functions, but Linux hasn't found them yet. Write a function to judge it as follows:
Bool islittleendian ()
{
Union
{
Long long;
Char char [sizeof (long)];
} U;
U. Long = 1;
If (U. Char [0] = 1)
{
Return true;
}
Else if (U. Char [sizeof (long)-1] = 1)
{
Return false;
}
Else
{
Throw "unknown addressing! ";
}
}
The last size-byte sequence conversion function:
Void endianconvert (unsigned int * value)
{
* Value = * value <24 | (* value & 0xff00) <8) | (* value & 0xff0000)> 8) | (* value & 0xff000000)> 24 );
}
Refer:
Http://www.dnbcw.com/biancheng/c/esbu62056.html
Http://hi.baidu.com/wbwssb/blog/item/7114224df46c6dc6d1c86ac6.html