www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/21/03:00:41

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Rhide Kb setup
Date: Fri, 20 Feb 1998 18:29:55 -0500
Organization: Two pounds of chaos and a pinch of salt.
Lines: 50
Message-ID: <34EE11F2.37C4@cs.com>
References: <Pine DOT SOL DOT 3 DOT 95 DOT 980218154235 DOT 12262A-100000 AT holly>
NNTP-Posting-Host: ppp231.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Mr J P Havers wrote:
> 

Can't help with your RHIDE problem, but...

> Also on a different note, I was just wondering what the difference is
> between a far pointer and a near pointer?

In protected mode, the term "near" refers to any pointer that addresses
memory within your program's address space.  The term "far" refers to
any pointer that addresses memory outside your program's address space. 
Please note that these terms are unrelated to their meaning in real mode
compilers such as Borland.

Typically, you hear near/far pointers being discussed as means of
accessing conventional memory, most often the VGA video memory at
0xa0000 or the text mode memory at 0xb8000.  Regardless of the
application, the two types of pointers work as follows:

 - To use "near" pointers to address conventional memory, you must alter
your program's data segment to encompass all memory on the computer. 
This is done via functions in <nearptr.h>.  You can then address
conventional memory locations by adding the value of the
__djgpp_conventional_base variable to the absolute address.  Near
pointers have the advantage of greatest speed, but there is a
corresponding element of danger:  you lose all benefit of memory
protection while they are enabled.  In addition, the code that performs
the enabling/disabling is slow and should be called as seldom as
possible.

  - The code for handling far pointers is defined in <farptr.h>.  It
allows you to read/write individual bytes, words, and longs from/to
addresses within a specific protected mode segment.  Conventional memory
may be accessed with the predefined _dos_ds variable.  Far pointers are
safer than near pointers, but usually require two instructions for each
byte/word/long written or read.  For fast loops, you can use one
function to set the selector and a different set to read or write in a
single instruction.

Additional details on these techniques can be found in the DJGPP
Frequently Asked Questions list, the libc documentation, and various
DJGPP tutorials on the net.

-- 
---------------------------------------------------------------------
|      John M. Aldrich       | "If 'everybody knows' such-and-such, |
|       aka Fighteer I       | then it ain't so, by at least ten    |
|   mailto:fighteer AT cs DOT com   | thousand to one."                    |
| http://www.cs.com/fighteer |                 - Lazarus Long       |
---------------------------------------------------------------------

- Raw text -


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