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.

ask some arm asm statement



 

1.     LDR     R3, =0x12345678

        in ccs v4.1 of tms570, compiled error is :

       Illegal symbol
     LDR     R3, =0x12345678

       Unexpected trailing operand(s)
     LDR     R3, =0x12345678

       in iar or keil mdk, it's ok!

      which is replacement asm in ccs4.1?

2.   asm call "C" function or "c"  call asm function

     has the "_" difference between asm functiom name and "c" function symbol name?

3. It seems that the asm indicant has a little difference from iar or keil mdk.

   example:

        keilmdk  import --> .ref ?

                        EXPORT -->   .global ?

        I am not sure!

4. where's the tms570 asm user manual?

     i want to know what's asm statement or indicant  supported by tms570 assembler !

  • Yang,

     

    1] TI Assembler code does not support pseudo instruction.

    In your example, LDR     R3, =0x12345678 is not real machine code part of ARM instruction set.

    The TI syntax for a load immediate is MOV R3, #0x12. The size of the immediate value cannot be greater than 8bits, but rotation are allowed.

    The following instruction example are possible and valid with TI assembler:

    mov R0, #0xFF
    mov R2, #0x88000000

    If you look the code generate by iar, you will see that multiple instructions are used to code your LDR     R3, =0x12345678

    2] A C function func1(int a, int b) can be call from assembly code as following:

         ldr r0, argument1
         ldr r1, argumentt
         bl _func1

    3] External symbols are symbols that are defined in one module and referenced in another module.
        You can use the .def, .ref, or .global directive to identify symbols as external:

                  .def       The symbol is defined in the current module and used in another module.
                  .ref       The symbol is referenced in the current module, but defined in another module.
                  .global The symbol can be either of the above.

    4] You can have a look to this other post. All links are provided to access the Assembly User's guide as well as C-Compiler User's guide.

    http://e2e.ti.com/support/microcontrollers/tms570/f/312/t/40677.aspx

    Best Regards,

     

    Jean-Marc

  • thanks Jean-Marc,

     i am just migrating a RTOS into TMS570,

    1)   use "LDR     R3, =0x12345678  " to load a function address, as is:

         LDR     R3, =func1

          move can't used.

          is there some workaround for pseudo instruction  " LDR     R3, =func1"?

    2)  

       "c" function:

          void func1(int i)

        {

        ........

        }

     

       asm funcion:

       .global  _func2
        .asmfunc

        _func2:

        ...........

        .endasmfunc

     

    in "c", call asm func2, like: 

         func2();

    in asm, call c func1, like:

       bl _func1

     

       is it right?

     

    3) ok, thanks. i am just looking for some asm instrction express in

       ARM Assembly Language Tools v4.6 User's Guide.pdf

    and

      ARM Optimizing C_C++ Compiler v4.6 User's Guide.pdf.

     thank a lot!

     

  • example:

        LDR     R3, =var1_name

        STR     SP, [R3]

         ..........                                               
        LDR     R3, =func1_name
        MOV     LR, PC
        BX      R3

      ..........

        LDR     R3, =var2_name

        LDRB    R4, [R3]
        SUB     R4, R4, #1
        STRB    R4, [R3]

     .............

     what's the workground on ccsv4.1 of tms570?

    thanks a lot!

     

     

     

  • Yang,

     

    Here is a quick test code to demonstrate what you have to do.

    Main.c

    extern Test();

    main()
    {

     Test();                      //Test is an assembly routine

    }

    Func1()
    {
     int a=3;
     int b=4;
     int c=0;
     c= a * b;
    }

    ===================================================
    Test.asm

         .global _Test
         .global _Func1
         .text

         .text


    _Test:
        str lr,[sp]              ; Save LR in Stack
        ldr r12, fptr          ; Load address of func1
        mov lr,pc             ; Get LR to return address
        bx r12                  ; Branch and exchange to func1
        ldr lr,[sp]             ; Restore LR
        mov pc,lr            ; Return from subroutine

    fptr .word _Func1

     

    Please let me know if this example is helpful.

     

    Best Regards,

     

    Jean-Marc

  • Jean-Marc:

            your code work well but a little error, the funtion and asm have same name, do not need "_".

           i already reference your code in my migrating asm code.

          i have solved this question.

          thanks!

  • Yang,

     

    I did some research concerning the "_".

    The TMS570 tools chain supports ABI and EABI format. In the legacy ABI, C function use to have an underscore.

    Function fool() will have a symbol name of _fool. This is no more the case in EABI. For more information, please you can have a look to the following document:

    4061.TMS470EABIMigration.pdf

     

    Best Regards,

    Jean-Marc