c からアセンブリ関数を呼び出そうとしていますが、エラーが発生し続けます。
.text
.globl integrate
.type integrate, @function
integrate:
push %ebp
mov %esp, %ebp
mov $0,%edi
start_loop:
cmp %edi,1024
je loop_exit
mov 8(%ebp),%eax
mov 12(%ebp),%ecx
sub %eax,%ecx
add %edi,%ecx
incl %edi
jmp start_loop
loop_exit:
movl %ebp, %esp
popl %ebp
ret
これは私のアセンブリ関数で、integrate.s というファイルです。
#include <stdio.h>
extern int integrate(int from,int to);
void main()
{
printf("%d",integrate(1,10));
}
これが私のCコードです。
function.c:5:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
/tmp/cciR63og.o: In function `main':
function.c:(.text+0x19): undefined reference to `integrate'
collect2: ld returned 1 exit status
gcc -Wall function.c -o 関数を使用してコードをコンパイルしようとすると、「統合への未定義の参照」エラーが発生します。
#include<(file path)/integrate.s>
しかし、それはうまくいきませんでした。ところで、アセンブリコードが何をしているのかは重要ではありません。