Date: Sun, 12 Apr 1998 12:11:23 +0300 (IDT) From: Eli Zaretskii To: David Boynton 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: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.