(Solved) how to compile a .asm file together with a c file ?
Posted: Fri Dec 07, 2007 10:21 am
if i wrote a asm file and a c file. i wanna call the c function in the asm file. say void main() function in test.c , and i worte this in the test.asm:
call _main
does it work ?
and how can i compile the two files together into a new file like test.bin ?
this is my first question , if you can't get the meaning (oh ,my poor english ) , i will say like this:
i have a file called main.c :
#include <stdio.h>
void main()
{
int total;
total = sum( 12, 12);
printf("%d\n",total);
},
and the sum function is defined in the sum.c file:
int sum( int a, int b)
{
return a + b;
}
how can i compile this two files correctly. if i just compile main.c using " gcc main.c", the gcc will write somethings as follows:
/tmp/ccoHLQeq: In function `main`:
main.c:(.text +0xf): undefined reference to `sum'
collect2: ld returned 1 exit status
i guess the ld will do it , but i really know nothing about ld ,and the gcc opptional paramters. can someone give some tips ?
thanks !
call _main
does it work ?
and how can i compile the two files together into a new file like test.bin ?
this is my first question , if you can't get the meaning (oh ,my poor english ) , i will say like this:
i have a file called main.c :
#include <stdio.h>
void main()
{
int total;
total = sum( 12, 12);
printf("%d\n",total);
},
and the sum function is defined in the sum.c file:
int sum( int a, int b)
{
return a + b;
}
how can i compile this two files correctly. if i just compile main.c using " gcc main.c", the gcc will write somethings as follows:
/tmp/ccoHLQeq: In function `main`:
main.c:(.text +0xf): undefined reference to `sum'
collect2: ld returned 1 exit status
i guess the ld will do it , but i really know nothing about ld ,and the gcc opptional paramters. can someone give some tips ?
thanks !