From: avly AT castle DOT net (An) Newsgroups: comp.os.msdos.djgpp Subject: Re: Problem when assembling external function using "asmdefs.h" Date: Tue, 08 Oct 1996 00:05:53 GMT Organization: The Castle Network, http://www.castle.net Lines: 67 Message-ID: <53c68b$28g@arther.castle.net> References: Reply-To: avly AT castle DOT net NNTP-Posting-Host: bridge49.castle.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Matthew B Kennedy 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 >.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