top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

I heard like far, near, huge pointer ? what it has significance and when these can be used ?

+3 votes
606 views
I heard like far, near, huge pointer ? what it has significance and when these can be used ?
posted Sep 20, 2013 by Ganesh Kumar

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+4 votes

'Near' pointers don't have a selector - they have an implied selector. They can access 64k off the virtual address space on a 286 and earlier and 4Gb of the addresss space on a 386 or later.

'Far' pointers have an explicit selector. However when you do pointer arithmetic on them the selector isn't modified.

'Huge' pointers have an explicit selector. When you do pointer arithmetic on them though the selector can change.

See this following link for the details,
http://www.thecareerplus.com/?page=resources&cat=10&subCat=25&qNo=21

answer Sep 20, 2013 by Satyabrata Mahapatra
+2 votes

In large data model (compact, large, huge) the address B0008000 is acceptable because in these
model all pointers to data are 32bits long. If we use small data model(tiny, small, medium) the above address won’t work since in these model each pointer is 16bits long. If we are working in a small data model and want to access the address B0008000 then we use far pointer. Far pointer is always treated as a 32bit pointer and contains a segment address and offset address both of 16bits each. Thus the address is represented using segment : offset format B000h:8000h. For any
given memory address there are many possible far address segment : offset pair. The segment register contains the address where the segment begins and offset register contains the offset of data/code from where segment begins.

A near pointer is 16 bits long. It uses the current content of the CS (code segment) register (if
the pointer is pointing to code) or current contents of DS (data segment) register (if the pointer is pointing to data) for the segment part, the offset part is stored in a 16 bit near pointer. Using near pointer limits the data/code to 64kb segment.

: Huge pointer is 32bit long containing segment address and offset address. Huge pointers are
normalized pointers so for any given memory address there is only one possible huge address segment: offset pair. Huge pointer arithmetic is doe with calls to special subroutines so its arithmetic slower than any other pointers.

answer Nov 9, 2013 by Vikas Upadhyay
But in case of gcc compiler there is no concept of near / far i guess.
yes gcc does not have that concept, in olden days when addressable memory size was more then the cpu size then to make memory access faster concept of 16 bit pointer i.e. near pointer and far&huge pointer 32bit was used. Now its obsolete.
Similar Questions
+2 votes

I read that files with .i extensions need not to be pre-processed.
Can someone tell me any use case which forces to make file with .i extension ?

0 votes

While reading shared library and PLT (Procedure Linkage Table) I came under a term Trampolines arrangement.

can any one share some info on it ?

0 votes

I came under a term "address space layout randomization" ? What is the meaning of it ?

Can any one give any example on it how it works and what happens in this feature ?

...