Most users of high level programming languages will not have encountered the endian issue because when they use a number, it always comes out looking the same as it went in. If they enter the number 10000 and then print it, it comes back out as 10000. Sometimes the user may dable with a debugger and still see the numbers expressed as expected (unaware that they are accutally stored in memory in reversed order). The way in which values too big to fit into an 8 bit byte are broken down and split across multiple bytes is called the byte order (often refered to the endianess of the machine).The order in which multi-byte quantities (such as 16 bit and 32 bit words) are stored on the PIC is upto the user since the PIC CPU does not handle multi-byte quantities natively. However the XCASM compiler assumes and is restricted to little endian byte order. The user may mix and match big and little endianess within the same program BUT the compiler will only work correctly with little endianess quantities.
Endian description
There is a certain elegance about little endianess that has prompted the adoption of little endianess as the endianess of the compiler. Consider how 8, 16, 24 and 32 bit values overlay each other when stored at address N.BIG ENDIAN
This is where a 16, 24 or 32 bit value is stored as most significant byte first, and least significant byte last.e.g.
the hexadecimal number 0x12345678 would be stored at memory address N as
VALUE ADDRESS 0x12 N+0 0x34 N+1 0x56 N+2 0x78 N+3 LITTLE ENDIAN
This is where a 16, 24 or 32 bit value is stored as least significant byte first, and most significant byte last.e.g.
the hexadecimal number 0x12345678 would be stored at memory address N as
VALUE ADDRESS 0x78 N+0 0x56 N+1 0x34 N+2 0x12 N+3 e.g.
the hexadecimal number 0x12345678 would be stored at memory address N asSo to calculate the address of the least significant byte of any 8, 16, 24 or 32 bit quantity stored in little endian format is the same regardless of size. Whereas it is not the same for quantities stored in big endian format. This complicates maters greatly when trying to do mixed size (8 bit / 16 bit) calculations on CPUs with limited indexing capabilities. This translates to more instructions and decreased performance.little endianess overlay
BYTE
VALUEWORD
VALUE24bit
VALUELONG
VALUEADDRESS 0x78 0x78 0x78 0x78 N+0 0x56 0x56 0x56 N+1 0x34 0x34 N+2 0x12 N+3 big endianess overlay
BYTE
VALUEWORD
VALUE24bit
VALUELONG
VALUEADDRESS 0x78 0x56 0x34 0x12 N+0 0x78 0x56 0x34 N+1 0x78 0x56 N+2 0x78 N+3