Mail Archives: djgpp/1996/10/08/18:54:33
Matthew B Kennedy <q9522772 AT helios DOT usq DOT edu DOT au> wrote:
>Hello. I've finished reading the AS assembler tutorial/guide, so
>I tried making a simple program in assembler (to be linked with C).
>The exact files and compile commands I have used are below. As you
>can see, I am using the "asmdefs.h" file to be able access the FUNC,
>ENTER and LEAVE macros. The problem is, the assembler spits-chips
>when it comes across the FUNC macro (see the compilation result).
>Thanks in advance,
>Matthew
>===== ADD.C ============================
>extern int _addint(int a, int b);
>void main(void)
>{
> int a, b, c;
> c = _add_int(a,b);
^^^^^^^^^^^^^^^^^
c = _addint( a, b );
> printf("%d+%d=%d\n",a,b,c);
>}
>===== ADD.S ============================
>#include "libc/asmdefs.h"
^^^^^^^^^^^^^^^^^^^^^
#include <libc/asmdefs.h>
>.file "add.c"
^^^^^^^^^^^^^
.file "add.s"
>.text
> .align 4
> FUNC(__addint)
> ENTER
> movl ARG1, %eax
> addl ARG2, %eax
> LEAVE
>===== COMPILATION COMMANDS ============
>[1] C:\DJGPP >gcc add.c add.s -o add
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gcc add.S add.c -o add.exe
>add.s: Assembler messages:
>add.s:6: Error: invalid character '(' in opcode
>add.s:7: Error: operands given don't match any known 386 instruction
>=======================================
>(Line 6 corresponds to the FUNC(__addint) line)
Also, it might be a good idea to use a different name instead of
"add.s" for the asm module, since you already have "add.c", and it
could be confused with the asm source generated from "add.c".
Cheers,
An
http://remus.rutgers.edu/~avly/djgpp.html
- Raw text -