delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/12/01/22:34:54

To: john hoeschele <john AT umdsun2 DOT umd DOT umich DOT edu>
Cc: mailing list <djgpp AT sun DOT soe DOT clarkson DOT edu>
Subject: Re: DOS memory allocation
Date: Thu, 01 Dec 94 18:44:06 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>

> I am doing a school project rewriting an older program for an old maching 
> and converting it into compatable code for Gnu C.  I have a buffer that 
> needs to be in low(DOS) memory for the hardware to work with it.  I have 
> looked in the dpmi documentation and it said to use:

It's better to post exactly what DOS call you want to use.  Then
your problem could be answered more precisely.
In general, you should first allocate a buffer in low memory, or
use the 4KB-long transfer buffer provided by GO32.  Its address
can be gotten from _go32_info_block.linear_address_of_transfer_buffer
(llok it up in the docs for the library).  You then use dosmemget()
or dosmemput() to move data to and fro.  You may also use movedata()
which is faster if you have a fairly large buffer, or the _farpeek/
_farpoke functions documented on <sys/farptr.h> header, if you have
only one word or byte to move.  You produce the segment:offset pair
from the linear address with mask and shift, like you wrote (but be
sure to only use the lower 20 bits of the address, or you're in for
some suprises...).

> another buffer in high memory for storage.  Would the dosmemget() and 
> *put() function work for transfer memory faster than transfering data 
> from the arrays in a loop?

You can't transfer data between low memory and your program's address
space like if they were arrays.  You must use the functions I mentioned
above.  Generally, movedata() is the fastest method right now, if you
have more than, say, 10 bytes to move.

- Raw text -


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