Mail Archives: djgpp/1996/05/08/10:27:59
On Tue, 7 May 1996, Enrico Horn wrote:
> If you need a pointer the best method is:
> #include <sys/nearptr.h>
> char *p;
> __djgpp_nearptr_enable();
> p=(char *)(0xb8000);
When posting code fragments that you didn't try to compile and run,
please at least say so, or point people to the place in the official docs
for more info. THE ABOVE CODE IS INCORRECT! Under certain circumstances
it will happily wipe out your hard disk!
The following is an example from the libc on-line docs which shows how the
nearptr facility should be used:
if (__djgpp_nearptr_enable())
{
short *screen = (short *)(__djgpp_conventional_base + 0xb8000);
for (i=0; i<80*24*2; i++)
screen[i] = 0x0720;
__djgpp_nearptr_disable();
}
The crucial difference is that `__djgpp_conventional_base' offset.
Without it you are writing to a random location, and since memory
protection is effectively disabled by `__djgpp_nearptr_enable', you can
really hurt your system.
- Raw text -