Mail Archives: djgpp/1997/04/16/01:02:23
Adam Haun wrote:
>
> This may be a stupid newbie lamer question, but anyway...is it
> possible to use a far pointer in DJGPP without resorting to all those
> strange funtions referenced in the help file?
Depends on your definition of far pointers. DJGPP programs do not need
far pointers in the traditional sense, because all code and data resides
in the same address space with an upper size limit of 4 GB. You only
begin needing far pointers (or their cousins, near pointers) to access
addresses outside your program's data space, such as the VGA memory. In
that case, there are at least three techniques that will work.
The simplest way to access an absolute address is as follows:
#include <sys/nearptr.h>
#include <string.h>
void poke_absolute_address( size_t addr, char byte, size_t length )
{
__djgpp_nearptr_enable();
memset( addr + __djgpp_conventional_base, byte, length );
__djgpp_nearptr_disable();
return;
}
Of course, this is both slow (in terms of the nearptr_enable and disable
functions) and unsafe (in that you can easily crash your computer with a
rogue address). See chapters 10, 17 and 18 of the DJGPP FAQ
(v2/faq210b.zip) for more information.
--
John M. Aldrich <fighteer AT cs DOT com>
* Anything that happens, happens.
* Anything that, in happening, causes something else to happen,
causes something else to happen.
* Anything that, in happening, causes itself to happen again, happens
again.
* It doesn't necessarily do it in chronological order, though.
--- Douglas Adams
- Raw text -