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.

Can I find a file which describes how to use C language to call assemble language in C64x+ device?

Other Parts Discussed in Thread: DM3730

Hello exports:

          The DM3730 is used by me. Can I find a file which describes how to use C language to call assemble language in C64x+ device? 

           Could you tell me how the arguments from C function transmit to the registers at the side of assemble function.

  • Hi Haitao,

    The usage of asm code from a C program is more general and not only related to C64x+. Read the linked article and pay attention on the InputOperands description which gives you ability to read C expressions by the instructions in the AssemblerTemplate.
    gcc.gnu.org/.../Extended-Asm.html

    BR
    Tsvetolin Shulev
  •  Shulev-XID:

            Thanks for your time and answer. As we know, different devices have different number of registers.  There are 64 registers which are divided into 2 parts named A-side and B-side. Is there a file which tells me which argumet map into which regster.

  • There is a C language function in file sum.c .

    int dotp(short a[], short b[] )
    {
        int sum, i;
        sum = 0;
        for(i=0; i<100; i++){
            sum += a[i] * b[i];
        }
        return(sum);
    }

    Now I am going to translate C code to assembly in sum.asm.

          MVK  .S1 100, A1 ; set up loop counter
       || ZERO .L1 A7 ; zero out accumulator
    LOOP:
          LDH   .D1 *A4++,A2 ; load ai from memory
       || LDH   .D2 *B4++,B2 ; load bi from memory
          SUB  .S1 A1,1,A1 ; decrement loop counter
     [A1] B    .S2 LOOP ; branch to loop
          NOP        2 ; delay slots for LDH
          MPY  .M1X A2,B2,A6 ; ai * bi
          NOP           ; delay slots for MPY
          ADD .L1 A6,A7,A7 ; sum += (ai * bi)
          ; Branch occurs here

    Now the problem is :

               How do I know the values of a and b will be mapped into the registers of A4 and B4 rather than others?

  • Shulev-XID,

    There is a C language function in file sum.c .

    int dotp(short a[], short b[] )
    {
        int sum, i;
        sum = 0;
        for(i=0; i<100; i++){
            sum += a[i] * b[i];
        }
        return(sum);
    }

    Now I am going to translate C code to assembly in sum.asm.

          MVK  .S1 100, A1 ; set up loop counter
       || ZERO .L1 A7 ; zero out accumulator
    LOOP:
          LDH   .D1 *A4++,A2 ; load ai from memory
       || LDH   .D2 *B4++,B2 ; load bi from memory
          SUB  .S1 A1,1,A1 ; decrement loop counter
     [A1] B    .S2 LOOP ; branch to loop
          NOP        2 ; delay slots for LDH
          MPY  .M1X A2,B2,A6 ; ai * bi
          NOP           ; delay slots for MPY
          ADD .L1 A6,A7,A7 ; sum += (ai * bi)
          ; Branch occurs here

    Now the problem is :

               How do I know the values of a and b will be mapped into the registers of A4 and B4 rather than others?