delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/08/10:27:59

Date: Wed, 8 May 1996 17:16:51 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Enrico Horn <enrico DOT horn AT prakinf DOT tu-ilmenau DOT de>
Cc: Bruno Kraychete da Costa <brunokc AT ufba DOT br>, djgpp AT delorie DOT com
Subject: Re: MK_FP, peekb and pokeb
In-Reply-To: <318F49B9.7BD4@prakinf.tu-ilmenau.de>
Message-Id: <Pine.SUN.3.91.960508170925.18314E-100000@is>
Mime-Version: 1.0

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 -


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