Pointers

1 view
Skip to first unread message

Rajas Lele

unread,
Aug 12, 2010, 7:20:19 AM8/12/10
to Knowledge Test
What are ``near'' and ``far'' pointers?

TheSuyog

unread,
Aug 12, 2010, 8:20:29 AM8/12/10
to Knowledge Test
Nice question! rarely asked and understood....

1st things 1st: The main memory is divided into segments, each segment
contains 64 KB of memory space, in Segment:Offset format, where
Segment is the segment number in the memory and Offset is the memory
address from 0 to 63.
The near pointer which is the fastest of all (near, far & huge) is a
16 bit pointer which operates only on the current segment, i.e., the
segment in which our program is loaded. It points to any object in the
current segment and does not worry about segment number.
While the far pointer is a 32 bit pointer which contains the segment
number as well as the memory address in that segment, hence can point
to any object in the memory. Far pointers can reference up to 1 MB of
memory.
The near pointers are the fastest because segment numbers don't have
to be dealt with while dereferencing the pointer, which is not the
case with far pointers.
Pointer arithmetic on far pointers does not modify segment part but
only the offset part. Segment part has to be modified separately.

A good link explaining near, far & huge pointers:

http://wiki.answers.com/Q/What_are_near_far_and_huge_pointers_in_C
http://en.wikipedia.org/wiki/Intel_Memory_Model#Pointer_sizes

rajas

unread,
Aug 12, 2010, 8:58:55 AM8/12/10
to knowledge-...@googlegroups.com
thanx dude....

TheSuyog

unread,
Aug 12, 2010, 10:00:04 AM8/12/10
to Knowledge Test
any time :)
Reply all
Reply to author
Forward
0 new messages