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.

[FAQ] MCU-PLUS-SDK-AM263X: [FAQ] How to compile different extensions of assembly files in MCU_PLUS_SDK or MCAL ?

Part Number: MCU-PLUS-SDK-AM263X

How to integrate .asm files in the SDK examples?

How to integrate .s and .asm files in MCAL examples when imported to CCS?

How to resolve illegal instruction errors in CCS assembly files?

  • This FAQ talks about how to compile different assembly file extensions in single project. Compiler errors like "illegal mnemonic specified" and "illegal instruction" are generated even when you give the right assembly syntax. This is because of missing compiler flags in the project. The steps to add these flags is also discussed in this FAQ.

    MCU_PLUS_SDK uses .S file extension for Assembly files, where as MCAL uses .asm file extensions for Assembly files.

    The following is the difference between these extensions:

    .s
    • Tiarmclang will interpret files with a .s extension as GNU-syntax Arm assembly source, invoking the integrated GNU-syntax Arm assembler.
    • This is automatically taken care in all the SDK examples, and no compiler settings need to be changed to compile .s files through SDK libraries.
    • To compile .s files in CCS through MCAL libraries, refer to the next section.
    .S
    • Tiarmclang will interpret files with a .S extension as GNU-syntax Arm assembly source that needs to be pre-processed, invoking the pre-processor first, and then the integrated GNUsyntax Arm assembler.
    • This is automatically taken care in all the SDK examples, and no compiler settings need to be changed to compile .s files through SDK libraries.
    • To compile .S files in MCAL, refer to the next section.
    .asm
    • Files with an .asm extension are usually assembly source files written with legacy TI-syntax Arm assembly language that can be processed by the standalone legacy TI-syntax Arm assembler.
    • To compile MCAL libraries with .asm files in CCS, we need to add -x ti-asm in the project Assembler settings. This lets to compile any .asm application files in the project.
    • To compile .asm files in SDK, refer to the next section.

    The compile, assemble, and link part of the development flow will look something like this:


    Compile .asm files through MCU_PLUS_SDK libraries in CCS:

    • Add the .asm file to your CCS project.
    • When this project is compiled directly, errors like "illegal instruction" are generated even though the syntax is right. 
    • Right-click on the .asm file → go to properties → Arm Compiler → Miscellaneous.
    • Now edit the section  "Miscellaneous assembly source specific flags" and add the flag "-x ti-asm" to it. This is shown in the below picture.

    • Then right-click on the project → go to properties → Arm Compiler→ Advanced options → Miscellaneous.
    • And edit the section  "Miscellaneous assembly source specific flags" and add the flag "-x none" to it. This is shown in the below picture.

    This should compile the code without errors for the SDK based project.

    Compile .s and .S files through MCAL libraries in CCS:

    • When MCAL project is imported into CCS, it is expected to add the "-x ti-asm" flag to the whole project to use the .asm files. Follow the below steps for Invoking the TI-Syntax
      ARM Assembler from tiarmclang:
    • Right-click on the project → go to properties → Arm Compiler→ Advanced options → Miscellaneous. 
    • Now edit the section  "Miscellaneous assembly source specific flags" and add the flag "-x ti-asm" to it. This is shown in the below picture.

    • Add the .s or .S files to your CCS project of MCAL.
    • When this project is compiled directly, errors like "illegal mnemonic specified" are generated even though the syntax is right. 
    • Right-click on the .asm file → go to properties → Arm Compiler → Miscellaneous.
    • Now edit the section  "Miscellaneous assembly source specific flags" and add the flag "-x none" to it. This is shown in the below picture.

    This should compile the code without errors for the MCAL based project.

    Compile the assembly files through command line:

    While using command line to compile and link files through tiarmclang, the source files/assembly files (.c, .cpp, .s, .S, .asm) are specified. Then the object files in which they will be converted into are specified. Compiler options/flags and Linker options are given in the same command line to link these specified files.

    Example of the Syntax is shown below:

     

    While declaring the .asm files in this command, "-x ti-asm" is placed right before the file, and "-x none" flag is placed after all the .asm files. Example Syntax for the compile side is shown below:

    Here, the “-x ti-asm” option indicates that the ti-asm-source1.asm file is to be processed by the TI-syntax ARM assembler, and the subsequent “-x none” option resets the input file type to a default state so that the tiarmclang compiler knows to process the c-source2.c input file as a C file.

    For more information on other compiler options for Assembly files, refer to section 2.4.3 Invoking the TI-Syntax ARM Assembler from tiarmclang  in TI_Arm_Clang_Compiler_Tools_User_Guide.