I'm using NASM and GCC (Assembly and C) compilers and I'm trying to make a function ad.asm in assembly and link it with my main.c by using the following commands:
nasm -f coff ad.asm
gcc -Wall -o main.exe main.c ad.o
and I get the following error message:
D:\Hwk3\Task2>gcc -Wall -o main.exe main.o ad.o
main.o(.text+0x63):main.c: undefined reference to `ad'
collect2: ld returned 1 exit status
Here's my code, can anyone tell me what I'm doing wrong?
main.c
ad.asmCode:#include <stdio.h> int ad(int,int); int main(int argv, char *argc[]) { int a,b,total; printf("Enter two integers"); scanf("%i %i", &a, &b); total=ad(a,b); printf("The sum of %i + %i = %i",a,b,total); return 0; }
Code:ad: push ebp mov ebp,esp mov eax,[ebp+8] mov ebx,[ebp+12] add eax,ebx mov esp,ebp pop ebp ret



LinkBack URL
About LinkBacks


