when I use the gcc to compile the two files, the compiler prompt the error ".S:2: Error: junk at end of line, first unrecognized character is `m'"
I don't know how to solve it.
No idea what this line is all about... void *memcpy(void *dst, void *src, size_t len);
Is this what u'r looking for (without line 3 from .c)?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int main()
{
char *src="Hello World!";
char *cnull= "\0";
char dst[20] = {0}; //holds the appended char arrays
printf("%s\n", dst);
memcpy(dst, src, 12); //place first 12 chars of src into dst
memcpy(dst+12, cnull, 1); //place 1 element from cnull to the end of dst
printf("%s\n", dst);
getchar();
return 0;
}
@soranz: Instead of using the standard includes, he is writing his own version of the function. The declaration in line 3 was telling the linker to search for the function in another source file or library. That source file happens to be written in asm.
@raine:
Sorry, I don't know your answer, This forum may be useful for such a question if no one else here knows: http://www.asmcommunity.net/
I do know that you can compile some asm code with a C compiler. Visual Studio 2010 lets me do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
int pow2(int num, int pow);
int main()
{
pow2(3,5);
}
int pow2(int num, int pow)
{
__asm
{
mov eax, num
mov ecx, pow
shl eax, cl
}
}
What version of GCC are you using? This compiles fine for me.
Also, I hope you're realizing that this is 16-bit code. Calling this function from a 32-bit or 64-bit program will fail horribly. And which 16-bit calling convention passes the first three parameters in ax, dx and cx? I'm not aware of any.