Mail Archives: djgpp/1998/04/12/05:11:50
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 -