MIPS上实现C和汇编互相调用?

lhfagemail 2012-02-21 08:52:28
因为最近的项目,需要在MIPS上实现C和汇编的互相调用,参照论坛以前的帖子

//test.c
#include <stdio.h>
int addtest(int a,int b);
int main()
{
int a,b,c;
a=1;
b=2;
c=addtest(a,b);
printf("a+b=%d\n",c);
return 0;
}
//addtest.s
.text
.global addtest
.ent addtest
addtest:
addu $2,$4,$5
j $31
.end addtest

参照论坛以前的帖子,在MIPS SDE1.0.0中,写了以上的C和汇编互相调用的例子,怎么编译不过去呀,有那位高手指点一下迷津,非常感激!





//test.c
#include <stdio.h>
int addtest(int a,int b);
int main()
{
int a,b,c;
a=1;
b=2;
c=addtest(a,b);
printf("a+b=%d\n",c);
return 0;
}
//addtest.s
.text
.global addtest
.ent addtest
addtest:
addu $2,$4,$5
j $31
.end addtest

//编译过程
mipsel-linux-gcc -o test addtest.s test.c
//执行过程
./test
a+b=3





...全文
203 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
WJN92 2012-02-22
  • 打赏
  • 举报
回复
编译器的问题吧
大熊猫侯佩 2012-02-21
  • 打赏
  • 举报
回复
编译不过去,出错信息?

21,459

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧