www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/12/05:11:50

Date: Sun, 12 Apr 1998 12:11:23 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: David Boynton <the_doc AT primenet DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: I'm sure this is a FAQ, but I couldn't find the answer.
In-Reply-To: <352fc5a5.399357@enews.newsguy.com>
Message-ID: <Pine.SUN.3.91.980412121059.3322U-100000@is>
MIME-Version: 1.0

On Sat, 11 Apr 1998, David Boynton wrote:

>	drp.buffer=wSegment << 16;

This is incorrect.  `__dpmi_allocate_dos_memory' returns the segment
of the allocated buffer.  To convert to a linear address, you need to
either multiply by 16 or shift left 4 bits:

	drp.buffer=wSegment << 4;

>	struct {
>		DWORD lsect;	// Starting sector
>		WORD nsects;	// # of sectors to read
>	        DWORD buffer;	// Where to put the stuff...
>	} drp;

This struct needs to be packed.  Otherwise, GCC will pad struct
members to make them aligned, for performance purposes.  See section
22.9 of the DJGPP FAQ list, for more details.

>  typedef unsigned int WORD;

This should be "typedef unsigned short WORD".  `int' is 32-bit-wide in
DJGPP.

>        memset (&in, 0, sizeof(__dpmi_regs));

This is unnecessary, but harmless.  `__dpmi_int' does this for you
automatically.

> 	// After this pbuffer contains nothing but garbage

That's because your .buffer member is computed incorrectly, and
because the struct declaration was wrong.  This caused DOS to put the
data in some address which is different from the one you think.

- Raw text -


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