【发布时间】:2014-09-26 04:17:59
【问题描述】:
我正在尝试查看我的教授给我们的测试程序,但我无法编译它。我在 Ubuntu 14.04 上。我正在用
编译它gcc -Wall test.c AssemblyFunction.S -m32 -o test
我在 64 位机器上运行代码时遇到了问题,并且读到添加 -Wall 和 -m32 将允许它工作。这样做解决了我遇到的第一个问题,但现在我得到了 error: undefined reference to `addnumbersinAssembly'。
这里是 C 文件
#include <stdio.h>
#include <stdlib.h>
extern int addnumbersinAssembly(int, int);
int main(void)
{
int a, b;
int res;
a = 5;
b = 6;
// Call the assembly function to add the numbers
res = addnumbersinAssembly(a,b);
printf("\nThe sum as computed in assembly is : %d", res);
return(0);
}
这里是汇编文件
.global _addnumbersinAssembly
_addnumbersinAssembly:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp), %eax
addl 12(%ebp), %eax # Add the args
movl %ebp,%esp
popl %ebp
ret
感谢您的宝贵时间。我一直在努力解决这个问题好几个小时,所以我很感激任何帮助。
【问题讨论】:
标签: c assembly compiler-errors