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.

Calling assembly from C in DSP 6713

Other Parts Discussed in Thread: CCSTUDIO

I have wriiten a test program for calling asm function from c.

source c file 

.
.
extern anc_asm_func();
.
.
echo(){
short k=100;
.
.
mk=anc_asm_func(mk);
outbuf[i] = 10*inbuf[i]*mk;
.
.

and anc_asm_func

.global _anc_asm_func
_anc_asm_func :
MV .L1 A4,A1 ; setup loop count in A1
SUB .S1 A1,1,A1 ; decrement loop count A1
NOP
MV .L1 A1,A4 ; result returned in A4
B .S2 B3 ; return addr to calling routine
NOP
.end

while compiling I am getting error 

[anc_asm_func.asm] "C:\CCStudio_v3.1\C6000\cgtools\bin\cl6x" -g -q -eoo67 -fr"./Debug" -i"." -d"CHIP_6713" -mv6710 -@"Debug.lkf" "anc_asm_func.asm"
"anc_asm_func.asm", ERROR! at line 7: [E0002] Illegal mnemonic specified
_anc_asm_func :

I have tried different combination of removing '_' or ':' but same error. Anyone who has worked on mixing code , please share the right way.

  • Manish,

    I have [politely and respectfully] ranted to many people on this forum to tell them not to write in C6000 assembly. It is difficult to learn and the C compiler does a better job than you can.

    1. Write the function you want in C and use the -k switch to keep the assembly output. Look at that file to see how the C compiler writes assembly. You can learn a lot from it.

    2. Use the optimizer to see how the compiler improves the assembly code. The non-optimized version is usually very inefficient assembly code.

    3. Read the TMS320C6000 Assembly Language Tools User Guide to learn the proper syntax and formatting for writing assembly files.

    4. Read the CPU & Instruction Set Reference Guide to learn the detailed timing requirements and execution details for the various instructions. There is a lot to know.

    5. Do not write assembly. Learn to read assembly if you want to be able to debug at the assembly level, but avoid writing it yourself.

    The error message mentions line 7, a mnemonic, and shows a line of code.

    - The line shown is not line 7 in the assembly code you show above. It is impossible to guess if the problem could be related to elsewhere in the file, up or down a line, or what.

    - You intended this line to be a label and not a mnemonic. Why do you think the assembler is treating it as a mnemonic and not a label? What in the Assembly Language Tools UG tells you the difference in syntax or format for the two types of items?

    Try using linear assembly. It may protect you from some of your mistakes. but it is better to just write the function in C.

    Do not write C6000 code in assembly. Write in C.

    Regards,
    RandyP

  • Thanks for your suggestion ! But calling assembly from C is requirement of my academic project. I won't need much command for the same.

    Now what I want is a sample asm program called from C. so that I can understand what did I do wrong in writing this part 

    ".global _anc_asm_func
    _anc_asm_func :"

    or its call and declaration in c file.

  • Manish,

    Please see my five (5) listed items above. That is how you do what you are asking how to do.

    Are any of those steps unclear? Have you tried any of them?

    Regards,
    RandyP