Mail Archives: djgpp/1997/11/03/15:00:51
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 -