Mail Archives: djgpp/1998/09/27/05:46:22
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 <stdio.h>
> 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
- Raw text -