Message-ID: <360E01A8.9217E4D7@mailexcite.com> Date: Sun, 27 Sep 1998 05:13:13 -0400 From: Doug Gale MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: DJGPP C code and NASM code... References: <906864530 DOT 10053 DOT 0 DOT nnrp-09 DOT c1ed260d AT news DOT demon DOT co DOT uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: oshawappp76.idirect.com Organization: "Usenet User" Lines: 63 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Chris Burgess wrote: > I'm testing out some interfacing of C code and Asmembler code. > I am using djgpp for this. It worked easily between AT&T syntax code (AT&T > syntax of the same code as below instead of intel format), just through > specifying the file funcn.s as part of djgpp, i.e. "djgpp test.c > funcs.s -otest.exe" - worked perfectly. > Now I would much rather use NASM so I translated it into the file shown > below. > I did "nasm funcn.asm -fobj -ofuncn.o" then compiled/linked into test.exe, > djgpp said it didn't recognise format, ok so -fobj = ms obj format, so I > tried: > "nasm funcn.asm -faout -ofuncn.o" > then > "djgpp test.c funcs.o -otest.exe" compiled and linked fine... > run test.exe it crashes the current shell, i.e. I am running a prompt under > win95, and windows says it has perfomed and illegal operation. a "general > protection exception". > ???? take out the "call_test" in funcn.asm and it works, but obviously the > program does nothing (in the way of output) anyway. And as I said before the > same file but in AT&T syntax works? > So can someone help me? What am I doing wrong. I don't want to be stuck with > AT&T syntax and using GAS. I need to write functions in assembler for C code > you see, so I am desperate to figure out what I'm doing wrong? > > Hope someone can help... > > Chris Burgess > > CODE.... > > test.c file: > > #include > extern void nasmproc(); > void test() > { > printf("test called from nasmproc\n"); > } > int main() > { > nasmproc(); > return 0; > } > > and the file funcn.asm > > extern _test > global _nasmproc > _nasmproc: push ebp > mov ebp,esp > call _test > leavenp: mov sp,bp > pop bp > ret Looks like your problem is the function exit code. Here fixed: leavenp: mov esp,ebp pop ebp