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.

SK-AM62A-LP: .asm offsetof and sizeof reference issue

Part Number: SK-AM62A-LP


Hello Team,

We tried of adding inline asm for calculating the OffsetOf in the .c file as below and it was working for us.

#define OsOffsetOf(type, member)  __builtin_offsetof (type, member)  //((osuint16) &(((structure *) 0)->member))

Inline asm : 

__asm__("mov r1, %c0" : : "i" (OsOffsetOf(OsCtrlParamType, ActiveTaskIndex)));

compiler cmake define : 

-D_CRT_USE_BUILTIN_OFFSETOF

If we try to add this code in assembly file we are facing errors and it is not successful.

So is there any equivalent code for calculating this OffsetOf and sizeof for a structure defined in .h file from the assembly file.

Attaching the previous ticket link for reference : https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1250832/sk-am62a-lp-ti-am62ax-asm-illegal-mnemonic-error

Please provide your feedback in this.

Thanks and Regards,

Naveen

  • I presume you use the LLVM/Clang based Arm compiler from TI.  The short name is tiarmclang.  

    is there any equivalent code for calculating this OffsetOf and sizeof for a structure defined in .h file from the assembly file.

    Unfortunately, no.

    Thanks and regards,

    -George

  • Hello Naveen,

    As George mentioned, this is not supported.  The options are:

    1. Use inlined assembly in a C file as alreadydone. This allows fairly seamless mixing of C and assembly code.
    2. Place the OffsetOf definition (or sizeof()) in a function in a C file that can be called from the assembly file (and link against it).
    3. Define an assembly macro in the assembly file (or assembly header file) using hand-coded assembly to do whatever is required.. 

    Regards,
    Krithika