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.

这是一个计算某个数阶乘的程序,是在CCS5中用C语言调用线性汇编(混合编程),可是编译通不过(单个文件编译可通过)?请赐教,越详细越好,我是新手,感谢



以下是c语言

#include<stdio.h>
void main()
{
short n=7;
short result;
result=factfunc(n);
printf("factorial=%d",result);
}

以下是线性汇编

.def _factfunc
_factfunc: MV A4,A1
SUB A1,1,A1
LOOP: MPY A4,A1,A4
NOP
SUB A1,1,A1
[A1] B LOOP
NOP 5
B B3
NOP 5
.end

  • 可能是COFF和ELF格式不兼容的问题
    去掉 _factfunc前面的"_"
    参见 SPRAB90 section 4.1 COFF Underscore Name Mangling

  • 谢谢,编译运行都可以通过了,但是有如下warning,虽然对结果没影响,可是还是想解决,谢了

    "../factorial.c", line 13: warning #225-D: function declared implicitly

    warning #10210-D: creating ".stack" section with default size of 0x400; use the -stack option to change the default size
    warning #10210-D: creating ".sysmem" section with default size of 0x400; use the -heap option to change the default size

  • henry liu 说:

    谢谢,编译运行都可以通过了,但是有如下warning,虽然对结果没影响,可是还是想解决,谢了

    "../factorial.c", line 13: warning #225-D: function declared implicitly

    warning #10210-D: creating ".stack" section with default size of 0x400; use the -stack option to change the default size
    warning #10210-D: creating ".sysmem" section with default size of 0x400; use the -heap option to change the default size

    在cmd文件中加入 

    -heap 0x400

    -stack 0x400  

    即可,提示你堆栈没有初始化长度