delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/08/09:07:30

Xref: news2.mv.net comp.os.msdos.djgpp:3560
From: Enrico Horn <enrico DOT horn AT prakinf DOT tu-ilmenau DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: MK_FP, peekb and pokeb
Date: Tue, 07 May 1996 15:01:45 +0200
Organization: Technische Universitaet Ilmenau
Lines: 43
Message-ID: <318F49B9.7BD4@prakinf.tu-ilmenau.de>
References: <Pine DOT A32 DOT 3 DOT 90 DOT 960429105811 DOT 68678A-100000 AT canudos DOT ufba DOT br>
NNTP-Posting-Host: ipisparc4.prakinf.tu-ilmenau.de
Mime-Version: 1.0
To: Bruno Kraychete da Costa <brunokc AT ufba DOT br>
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Bruno Kraychete da Costa wrote:
> I tried somethink like:
>         char *p;
>         p=(char *)(0xb8000);
>         ... but I've got a SIGSEGV signal. Since I've never worked 
>with protected mode, I don't know how to do that work.

Yes you can't do that under protected mode, cause the memory outside
your data segment (segment may not be the right word) is not directly
accessible. All the memory is PROTECTED (that's why it's called
protected mode 8)). However there are a few possibilities to make that.
If you need a pointer the best method is:
   #include <sys/nearptr.h>
   char *p;
   __djgpp_nearptr_enable();
   p=(char *)(0xb8000);
     .
     .
     .
at the end of your program (or if you don't need the pointer anymore):
   __djgpp_nearptr_disable();

The main work is done by __djgpp_nearptr_enable which sets your data
segment to the size of all available physical memory (the method is
called FAT DS) so that you can use a nearptr to access every memory
location. But be careful: a wild pointer can destruct memory contents
(real DOS programmer don't care about that, I do).
But there are also more secure methods:
         1. _farpokeb/_farpokew/_farpokel to write one/two/four bytes
              at a specific memory location (there are _farpeek calls to               
              read bytes)

         2. dosmemputb/dosmemputw/dosmemputl to write more
            bytes/words/longs at a time (there are dosmemget calls)

Consult the library reference for the syntax.
Regards,
Enrico.
/---------------------------------------------------------------------\
|Enrico Horn               Tel. 036738/41929                          |
|07426 Lichta              E-mail: enrico DOT horn AT prakinf DOT tu-ilmenau DOT de  |
|Ortsstrasse Nr. 14        http://www.prakinf.tu-ilmenau.de/~ehorn    |
\---------------------------------------------------------------------/

- Raw text -


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