This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BE-32 Endianness insights

Hello,

I have declared below variables as a global variables :

extern   uint16       A_u16;
extern   float32      B_u16;
extern   uint16       C_u16;
extern   uint16       D_u16;

And below is the excerpt from the map file for it.

00001f78    -      A_u16  -   4 Bytes
00001f7c    -      B_f32  -   4 Bytes
00001f80    -      C_u16  -   2 Bytes 
00001f82    -      D_u16  -   2 Bytes

Here the size allocated for float32 is 4 bytes and the size allocated for third and fourth uint16 variables is two bytes whereas for the first uint16 variable is 4 bytes.

I want to know the reason and the way memory is organised in such cases.

I am using CCS 5.4 with TI-4.9.5 as the compiler and be32 endianness.

Thanks in advance.

Regards,

Manoj

  • uint16 - unsigned short is 16 bit, in other words, 2 bytes.

    float32- float is 32bit, in other words, 4 bytes.

    If it is '2 bytes', the compiler will align it to the 16 bit boundry.

    If it is '4 bypte'. the compiler will align it to the 32 bit boundry.

    In your case, the compiler allocate 16 bit to the 1st uint16 data. Next, it need to allocate 32bit spce to the float, and it has to be aligned with the 32-bit boundry. This explains what you saw.

    Regards,

    Haixiao

  • Thanks Weng, 

    It answers my question but is there any document or a link where this memory structuring and management is explained in detail.

    And also I want to know whether this behavior is the characteristic of be32 endianness or some other concept goes in here.

    Regards,

    Manoj

  • This is the concept goes everywhere, almost all the TI devices I knew, compiler will align the 16 bit data to 16 bit boundry, 32 bit data to 32 bit boundry and 64 data to 64 bit boundry. It applies to int, float, doule, long long, short, but NOT structure.

    The main reason for this is to save the time of "load/save data from/to memory"

    Regards,

    Haixiao

  • Thanks Haixiao..