Mail Archives: djgpp/1998/09/26/23:00:59
From: | "Chris Burgess" <jazz AT uknet DOT demon DOT co DOT uk>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | DJGPP C code and NASM code...
|
Date: | Sun, 27 Sep 1998 03:47:51 +0100
|
Message-ID: | <906864530.10053.0.nnrp-09.c1ed260d@news.demon.co.uk>
|
NNTP-Posting-Host: | uknet.demon.co.uk
|
Lines: | 60
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
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
- Raw text -