| raine (2) | |||||
|
now I'm trying call the subroutine writen by GNU asm in .C file.To do this, I just want to understand some way to pass the parameter. the .c file follows that:
the .S file follows that:
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. | |||||
|
|
|||||
| soranz (472) | |||
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)?
| |||
|
Last edited on
|
|||
| raine (2) | |||
gcc prompt the .S file instead of .c file
| |||
|
|
|||
| Stewbond (1676) | |||
|
@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:
| |||
|
Last edited on
|
|||
| soranz (472) | |
| @Stewbond: Gotcha. Thanks | |
|
|
|
| P C (5) | |
|
First, here is a working example (complete program)... __asm__(".global main ; main: ; enter $0x30, $0 ; pushl $buffer ; call system ; add $4, %esp ; xorl %eax, %eax ; pushl %eax ; leave ; ret ; buffer: ; .byte 0x74 ; .byte 0x6f ; .byte 0x50 ; .byte 0x00 ;"); Second, place your assembly code inside the quotes of this function... __asm__(""); | |
|
|
|
| P C (5) | |
| When you have multiple parameters, you push them onto the stack in reverse order. | |
|
|
|
| majidkamali1370 (202) | |
| As P C said, use inline assembly with __asm__ keyword. | |
|
|
|
| UdAy ShArMa (14) | |
| c++ is the "in" computer language(c is pretty good also) | |
|
|
|
| Athar (4383) | |
|
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. | |
|
Last edited on
|
|
| ritka (21) | |||||||
i don' know wether gcc can compile asembler. i think you should use the assembler:
i hope the comand is right, but i think so. this should create a binary object file of your assembler code. than you need to tell gcc that memcpy() is an extern function:
now you should be able to compile the whole thing with
or use inline assembler | |||||||
|
Last edited on
|
|||||||