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.

Why a opcode can't using in CCS 3.3



 I am  coding  using  Linear Assemble in CCS3.3 ,target: a C64X chip,

   the address i access,need increasing by degrees.for example:  ptrout +=ncols;

so :I using the opcode addu : the following is the code in my *.sa file

             stnw sum,*prout

             addu prout,piany_col,prout

 

but,the compile information:

       "vert.sa", ERROR!   at line 20: Illegal operand combination
             addu prout,piany_col,prout

 

 

PS: Whether there is any other instruction support unsigned?

 

the project:

       

  • Just use

    add prout,piany_col,prout

    Because the registers are all the same size, it doesn't make any difference whether the operands are signed or unsigned.  ADDU is intended for use when the destination is a 40-bit register pair.

  •  hello ,

     thank for  your reply!

    Another interesting question is how do I use this addu instruction?

    Whether it is no longer in use.

     

    PS:

    1.ADD —      Add  Two Signed Integers Without Saturation

         

    2.ADDU —       Add  Two Unsigned Integers Without Saturation  

  • ADDU only makes sense if the destination is a 40-bit register pair.  It has two forms:

            ADDU A5, A3, A1:A0
            ADDU A5, A3:A2, A1:A0
    
  •  

    Good!

     I understand, thank you!

  • another question, can you help me ?

    i want to finish a multiply:  -32768 x 32768.

    so the code is follwing: 

    mpy in1,in2,result
    stnw in1,*out1++
    stnw in2,*out1++   
    stnw result,*out1++

    I printf them :  printf("%x\n",out1[i]);

    FFFF8000
    8000
    40000000

    you know that is worng! why ?  

    is that mpy can finish this task :Multiply Signed by Signed, 16 LSB × 16 LSB

     

     

  • Try

    mpysu in1, in2, result
  • I found that I will not use the instructions: shr

    WHEN  the code :

                 shr A1,15,A1                       (A1 is a 32bit register)

    The instructions will be added automatically according to the sign bit 0 or 1.

       BUT:when i codeing following :

           shr A2:A1,15,A2:A1

    for example:

    A2:A1:

    oxffffffff   :0xfffffff =>0xff : 0x fffe1fff

    0x2 :0x1 ====>0x0: 0x40000

     

    The instructions are all added 0, regardless of the highest level of 64

     

     

  • The upper 24 bits of the high register are ignored when doing a 40-bit shift.  Only bit 39 matters when determining the sign of the result.

  • I get 64 - bit register set, the data obtained by MPY32 instructions, the following:

    mpy32 in2,in1,result4:result3

    Then, I need to shift the 64 - bit data.result4:result3 .

    I don't know why the SHR only 48-bit effectively.

    Can you give me some help,SIHFT 64 set of registers.

  • C6000 does not have a 64-bit shifter, it has only a 40-bit shifter.  You have to construct a 64-bit shift from other, smaller shifts. For example, here is 64-bit right shift by 1:

               SHL     A5,0x1f,B4
               SHRU    A4,0x1,A3
    
               OR      B4,A3,A4
     ||        SHRU    A5,0x1,A5
  • Thank you for your reply,

             You are so clever to solve the problem.

    but If i consider the 64th sign-bit. i think the sifhter code:

               SHL     A5,0x1f,B4
               SHRU    A4,0x1,A3

               OR      B4,A3,A4
    ||        SHR    A5,0x1,A5

    I have already tested it,Thank you again for your help!

     

    Can I ask you another question?

    1.how to implement subtraction with 64-signed bit.

    Such as a model

             _SUB  A5:A4,A3:A2,A3:A2

    2. in TMS320C6000 Integer Division  SPRA707 - October 2000 .

    int sdiv(int num, int den) ,this function can complete 32-signed bit division.

    but i want a function that a 64-signed bit are divided by a 32-signed bit. or  a 64-signed bit are divided by a 64-signed bit.

     I am doing assem.bly work In my company, at the same time I need your guidance(TI documents or some program code).

    best  wishes to you and your family !

     

     

  • I didn't think up that solution for 64-bit shift, I let the compiler do it for me.  I wrote:

    unsigned long long func(unsigned long long x) { return x >> 1; }

    and looked at what the compiler generated.  Similarly, we can do the same thing for subtraction:

    long long func(long long x, long long y) { return x - y; }

    The compiler generates:

               SUBU    A4,B4,A7:A6
    
               SUB     A5,B5,A3
    ||         EXT     A7,24,24,A5
    
               ADD     A3,A5,A5 
    ||         MV      A6,A4  
    

    longya lang said:
     a 64-signed bit are divided by a 64-signed

    Call __c6xabi_divlli (__divlli in COFF mode) instead of writing code to do so, it's what the compiler will do.

  • I think you taught me a method of learning rather than merely a knowledge. I will study hard and make use of C6x compiler. Thank you for your guidance!

    Another question: imath64.obj (.text:__c6xabi_divlli) .Is this funtion  defined in imath64.c file?And in which lib? 

    This function may be in the rts64plus.lib.i think.

     

     Here is the thing.

    Earlier, I used the function _divlli() in the mian. C file ,and call it sucessfully.I can get the right result.

    Then I tried to call the _divlli() in the assembly file. but failed!(The figure below)
    In addition, in that assemble file,the function sdiv()which is my-coding function can using successfuly!

    i don't know what happened? "undefined   symbol" Means that the lack of libraries, but when I called _divllli() in C file,we didn't meet with that problem .i think this function is in rts64plus.lib. so,

     i copy the function code from imath64.c to main.c.and call it in assmble file.the compiler print: __divlli is defined multiple times. i know all the thing happen in the linking section .

    So,in the assembly code,How can i call a  function which is in a .lib file . For example, _devlli() in rts64plus.lib.

    PS:

    this is my function for 64-signed bit DIV.

    long long divlli64(long long a, long long b)
     {
      /*-----------------------------------------------------------------------*/
       /* CHECK SIGNS, TAKE ABSOLUTE VALUE, AND USED UNSIGNED DIVIDE.           */
       /*-----------------------------------------------------------------------*/
       long long sign  = (a^b)>>63;    
      unsigned long long ua=(a==LLONG_MIN?a:llabs(a)); 
      unsigned long long ub=(b==LLONG_MIN?b:llabs(b));
        unsigned long long q =_divull(ua,ub);

       if (b == 0)
           return a?(((unsigned long long)-1) >> 1)^sign : 0;
                             /* saturation value or 0 */
       return sign?-q:q;
     }

    but i can't using it ,when i pass a 64-bit para to  it. the following is the code:

     .call in6=_divlli64(in3:in4,in1:in2)

    the compiler print: >> internal error: Missing symbol table entry for in3:in4

    (The figure of the project is at the bottom)

     

  •  

    Hello Archaeologist!

    In coding some assembly  file ,i have encountered some trouble: 64-bit div.for example,using the _divlli() which you told me yesterday in my  assembly code.

    These problemsI have already submitted in the following URL.

    http://e2e.ti.com/support/development_tools/compiler/f/343/t/287024.aspx

  • You need the information contained in the TMS320C6000 Optimizing Compiler v7.4 User's Guide (SPRU187U) http://www.ti.com/lit/ug/spru187u/spru187u.pdf section 7.5 "Interfacing C and C++ With Assembly Language", section 6.12 "Object File Symbol Naming Conventions (Linknames)," and chapter 5 "Linking C/C++ Code"

  • try to produce asm files for the project by using properties and then check what is the symbol generated for the function, i faced same problem, anyways that was solved because it is adding ''__Fv'' with the symbol.

    ex: "myfun" is the function name

    "_myfun__Fv" assembler generated symbol for BIOS project.

  • See section 6.12 "Object File Symbol Naming Conventions (Linknames)", where it talks about name mangling.

    See also Chapter 9, "C++ Name Demangler"

    If myfun is a C function, you must prototype it as extern "C" if you intend to call it from C++ code.

  • Dear my friend!

                     Thank you for all your help these days!

                    I have already completed  the task , transforming the fixed-point floating-point program  to a fixed-point  program.Under the guidance of you, I was able to complete. Thank you very much.

                                                                                           

        

     PS: the last probelom,The last question does the problem of naming convention.