The Endiannes is related to the reading/writing format of microcontroller from/in memory. Basically, memory is a large array, where in you can store or retrieve data in/from different locations. You can access the data by providing address of the a particular location.
If your memory can save single byte(8-bits) on a location and you need to save one word(4 byte) or 16-bit variable in the memory. You have to split the data in 8-bit/one byte format and save it on different location. Here, the Endianness of microcontroller comes in the picture.
Example: To save a 32-bit(4-byte) data into memory, say 0x36DF4A0C
In Big-endian, the most significant byte of the data will be saved at the first address i.e the lowest address location.
For 8-bit
........... | 0x36 | 0xDF | 0x4A | 0x0C | ........... |
For 16-bit
........... | ........... | 0x36DF | 0x4A0C | ........... | ........... |
In Little-endian, the most significant byte of data will be saved at the end of the address i.e the highest address location.
For 8-bit
........... | 0x0C | 0x4A | 0xDF | 0x36 | ........... |
For 16-bit
........... | ........... | 0x4A0C | 0x36DF | ........... | ........... |
In middle-endian or mixed-endian, the first byte(16-bit) will be stored in little-endian format and next byte will be stored in the next location with little-endian format.
........... | 0xDF | 0x36 | 0x0C | 0x4A | ........... |
No comments:
Post a Comment