delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/11/05/13:43:54

Message-ID: <3A05AA54.229C4FAE@magma.net>
Date: Sun, 05 Nov 2000 13:43:32 -0500
From: Danny Byers <dan AT magma DOT net>
X-Mailer: Mozilla 4.7 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: using COFF object file from MASM to compile C
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1001105082457 DOT 27000C-100000 AT is>
Reply-To: djgpp AT delorie DOT com

excellent! I was trying to get things to work after I posted the message and I
found that (since I am using NT) long filenames under dos isn't enjoyed for
djgpp... I made my object file name smaller and I was able to link up...

now that I can link up and use mixed mode, I am finding that I get a GPF error
as soon as I try to call back a function in my C program... here is my code:

getc.asm --------------------------------------------
.MODEL SMALL
EXTRN _PrintInfo:PROC
.STACK 100H

.CODE

PUBLIC _GetChars
_GetChars PROC

BEGIN:
 push BP
 mov BP,SP
 mov AX,[BP+4]
 call _PrintInfo
 pop BP
 ret
_GetChars ENDP
 END

getn.c ---------------------------------------------------------------
#include <stdio.h>

int main() {
 int size;
 char PrintInfo(char);
 extern void GetChars(int);

 printf("Please enter the length of the string: ");
 scanf("%d", &size);

 GetChars(size);

 return(0);

}

char PrintInfo(UserInput) {

 printf("testing!");
 return(0);
}

Any idea as to why I am getting a GPF error with this code? Is it a problem
related to Protected Mode??

Best Regards,
Dan

Eli Zaretskii wrote:

> On Sat, 4 Nov 2000, Danny Byers wrote:
>
> > Hey! I am using MASM 6.11 (which can output the COFF format object
> > files) and I need to interface my assembly code with some C functions
> > that I have written.
>
> Be prepared for a bumpy ride: people who tried this reported problems.
>
> One thing you definitely want to make sure is that the assembly code was
> written for protected mode, not for real mode.  See section 17.3 in the
> FAQ for more about this.
>
> > How can I use DJGPP with the object file that I got from MASM? I am new
> > to using DJGPP. What would be the command (ie. gcc file.c asmcode.obj)
> > to include the object file so that my C code will work with the assembly
> > code?
>
> The command you show above is correct: just include the object file(s) as
> part of the link command line.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019