The byte order of the CPU is divided into big-endian mode and small-end mode.
Big-endian: The low byte of a data word is stored to the high address, and the high byte is stored in the low byte.
Small end opposite. It is advisable to remember only one, lest confusion be remembered.
1 BOOLcheckcpuislittleend ()2 { 3 Union W4 {5 intA;6 Charb;7 };8W.A =1;9 if(w.b = =1)Ten return true;//Small terminal mode One return false; A}
When I looked at the code, the only question was: When I get a variable of char type, should I get it from the high address or low? The results are not yet found, but the output from the other blog's programs might infer that a variable that gets a char type is a value obtained from a low-byte address of the Union type. Thus, we can infer the following: If the value of W.B is 1, the low-byte address is 1 and the low-byte data is stored in a low-byte address. That is, the small-end mode. Otherwise, the big-endian mode.
A program to determine whether the CPU is a big or small end