www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/03/15:00:51

From: George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Question about __dpmi_allocate_dos_memory
Date: 3 Nov 1997 17:24:11 GMT
Organization: Oxford University, England
Lines: 40
Message-ID: <63l1br$f5e$1@news.ox.ac.uk>
References: <199711031208 DOT XAA05407 AT rabble DOT uow DOT edu DOT au>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Mon, 3 Nov 1997 12:08:25 GMT in comp.os.msdos.djgpp Brett Porter <bporter AT rabble DOT uow DOT edu DOT au> wrote:
: Hi

: I've noticed that __dpmi_allocate_dos_memory has superseded (and much
: simplified) calling this DPMI function, over the
: _go32_dpmi_allocate_dos_memory equivalent.

: But the routine gives you back just a selector and a segment.

: So if I have a structure MyStruct, I want to call like this:

: movedata( _my_ds(), (int )&MyStruct, DosSelector, 0, sizeof( MyStruct));

: Is this right?

Assuming DosSelector is what is filled in by the DPMI function?  I'm
not sure, but that's not how I do it.  I only use the selector to free
the block (__dpmi_free_dos_memory should be passed the selector).
When accessing the block, I use DOS's DS (I think it's in _dos_ds),
and (segment*16) as the offset into that selector.  So:

segment = __dpmi_allocate_dos_memory( (sizeof( MyStruct ) + 15)/16, &selector );
movedata( _my_ds(), (int)&MyStruct, _dos_ds /* ? */, segment*16, sizeof( MyStruct ) );
__dpmi_free_dos_memory( selector );

: My question is about the 0 ... I have just assumed this is the offset to
: use, because there is no offset returned. Likewise when I pass the segment
: returned from the allocate to __dpmi_int with an es:ebx combination: I
: assume again that the allocation aligns it on a segment boundary?

The offset into the segment is indeed 0; so the absolute offset into
the DOS selector is (segment*16).  What you write above should be
correct, though, for __dpmi_int; fill in the segment with what is
returned by the allocate function, and the offset of the start of the
block is 0.

-- 
Regards,

george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


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