delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/04/15:26:24

Date: Sat, 4 Oct 1997 19:28:00 +0100
From: Richard <richard AT sdsoftware DOT co DOT uk>
Message-Id: <199710041828.TAA00179@sdsoftware.co.uk>
To: djgpp AT delorie DOT com

Please can you help me. I have used gnu-c for several years under linux.
I am trying to port one of my applications to use djgpp under DOS, (The
application already works under DOS using microsoft 'C', Quick C and Turbo C
For the dos version of my application I need to get the disk transfer address.
My other dos versions use routines written in 8086 assembler for this, compiled
using MASM. The code is not compatible with as. So I have tried to use C
instead. the problem is I need to use intdosx as the interrupt call I use (2fh)
returns the DTA in ES:BX, when I call intdosx I get a general protection error.
Assuming it may be that intdosx needs a valid DS and ES I tried allocating
conventional memory, and using the segment returned for DS and ES, it did not
help. I have tried looking at my documentation downloaded from sunsite and
did not find any suggestion that intdosx needs any prefixed values in the
segement registers. Can you help? If it helps I used go32-v2.
My code goes as follows :-

/* getvolid.c - 'C' version of getvolid.c */
#include <stdio.h>
#include <dos.h>
#include <dpmi.h>


long getvolid();

main(int argc, char **argv)
{
union REGS r;
struct SREGS s;
_go32_dpmi_seginfo info;
char xfcb[48]={-1,0,0,0,0,0,8,0,'?','?','?','?','?','?','?','?','?','?','?'};
long ret;

info.size=4;
if (_go32_dpmi_allocate_dos_memory(&info)==-1)
        {                               /* malloc 64 bytes of conventional
                                           memory */
        fprintf(stderr,"failed to malloc - errno=%d\n",errno);
        exit(0);
        }
dosmemput(xfcb,48,info.rm_segment*16);

r.h.ah=0x2f;            /* mov ah,2fh */
s.ds=info.rm_segment;   /* does it need a valid ds? */
s.es=s.ds;
intdosx(&r,&r,&s);      /* int 21h get DTA in es:bx */
	/*** this gives a general protection fault ***/
}
                                   

I have looked in the FAQ file as suggested but as far as I can see I cannot
find anything that relates directly to my query. 

- Raw text -


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