Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ User's Guide - near pointers are generally the most efficient type of pointer because they http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Near pointers are generally the most efficient type of pointer because they
are small, and the compiler can assume knowledge about what segment of the
computer's memory the pointer (offset) refers to.  Far pointers are the most
flexible because they allow the programmer to access any part of the
computer's memory, without limitation to a particular segment.  However, far
pointers are bigger and slower because of the additional flexibility.

Based pointers are a compromise between the efficiency of near pointers and
the flexibility of far pointers.  With based pointers, the programmer takes
responsibility to tell the compiler which segment a near pointer (offset)
belongs to, but may still access segments of the computer's memory outside
of the normal data segment (DGROUP).  The result is a pointer type which is
as small as and almost as efficient as a near pointer, but with most of the
flexibility of a far pointer.

An object declared as a based pointer falls into one of the following
categories:

 .  the based pointer is in the segment described by another object,
 .  the based pointer, used as a pointer to another object of the same type
    (as in a linked list), refers to the same segment,
 .  the based pointer is an offset to no particular segment, and must be
    combined explicitly with a segment value to produce a valid pointer.

To support based pointers, the following keywords are provided:


     __based
     __segment
     __segname
     __self

The following operator is also provided:


     :>

These keywords and operator are described in the following sections.

Two macros, defined in MALLOC.H, are also provided:


     _NULLSEG
     _NULLOFF

They are used in a manner similar to NULL, but are used with objects
declared as __segment and __based respectively.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson