1. Little-Endian(小端儲存),即將低位元組的資料存放區於低地址中,Big-Endian(大端儲存)反之。
2. 小端儲存稱為Intel模式,大端儲存稱為Motorola模式。
3. C51中LCALL指令將下一指令的執行地址壓入堆棧中(堆棧地址由低向高增長),先存入低位元組地址,再存入高位元組地址,亦即使用“小端模式(Intel模式)”;除此之外,C51中的其它指令和資料,均使用“大端模式(Motorola模式)”。
The 8051 is an 8-bit machine and has no instructions for directly manipulating data objects that are larger than 8 bits. Multi-byte data are stored according to the following rules. The 8051 LCALL instruction stores the address of the next instruction on the stack. The address is pushed onto the stack low-order byte first. The address is, therefore, stored in memory in little endian format. All other 16-bit and 32-bit values are stored, contrary to other Intel processors, in big endian format, with the high-order byte stored first. For example, the LJMP and LCALL instructions expect 16-bit addresses that are in big endian format. Floating-point numbers are stored according to the IEEE-754 format and are stored in big endian format with the high-order byte stored first. --引用參考:Keil Cx51 User‘s Guide -> Appendix -> E. Byte Ordering.--http://www.keil.com/support/man/docs/c51/c51_xe.htm
4. Keil編譯器不能按使用者需求設定大小端的儲存模式。
SYMPTOMSMy hardware's set up for big endian, but the compiler seems to be storing things little endian. Is there a compiler option to reverse the way data is stored?CAUSEAt this time, there is no functionality in any of the compilers to effect a "global" change in the way data is stored.--引用參考:http://www.keil.com/support/docs/730.htm
5. 8051系列MCU中,用C語言進行編程時,資料的儲存模式由編譯器(Compiler)決定,如Keil C51 Compiler 4.0版本開始使用“大端儲存模式”,而較早前的編譯器版本中使用的是“小端儲存模式”。
Version 4.0 DifferencesHome » Appendix » B. Version Differences » Version 4.0 DifferencesByte Order of Floating-point NumbersFloating-point numbers are now stored in the big endian order. Previous releases of the C51 compiler stored floating-point numbers in little endian format. Refer to Floating-point Numbers for more information.--引用參考:http://www.keil.com/support/man/docs/c51/c51_xb_ver4dif.htm
6. 主流MCU架構關於endian的配置:
使用小端(Little-endian)的架構:最常用x86架構(包括x86_64),還有 6502 (including 65802, 65C816), Z80 (including Z180, eZ80 etc.), MCS-48, 8051, DEC Alpha, Altera Nios, Atmel AVR, SuperH, VAX, 和 PDP-11 等等;使用大端(Big-endian)的架構: Motorola 6800 and 68k, Xilinx Microblaze, IBM POWER, system/360, System/370 等等。支援配置endian的架構:如下架構有配置endian為大端、小端中任一種的功能, ARM, PowerPC, Alpha, SPARC V9, MIPS, PA-RISC 和 IA-64 等等。--引用參考:http://smilejay.com/2012/01/big-endian_little-endian/
--編者註:ARM架構中,可通過對功能寄存器進行設定,從而切換至Big-Endian或Small-Endian儲存模式。