[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]


    Search the Q&A Archives


...NEAR FAR POINTER AND FAQS ON POINTERS

<< Back to: comp.compilers monthly message and Frequently Asked Questions

Question by SIRISHA
Submitted on 9/2/2003
Related FAQ: comp.compilers monthly message and Frequently Asked Questions
Rating: Rate this question: Vote
WHAT IS NEAR FAR POINTER AND FAQS ON POINTERS


Answer by rahul
Submitted on 1/25/2004
Rating:  Rate this answer: Vote


 

Answer by hemanthdas
Submitted on 8/31/2004
Rating: Not yet rated Rate this answer: Vote
i like to have the details about pointers

 

Answer by Vadiraj Purohit
Submitted on 11/11/2004
Rating: Not yet rated Rate this answer: Vote
near Pointers:
Pointers to near objects are stored using two bytes (16 bits). The bytes are stored little endian or low to high order. In the tiny memory model, near pointers contain a 16-bit memory address. In all other memory models, near pointers contain a 14-bit offset in bits 0-13 and a 2-bit DPP selector in bits 14 and 15.

far Pointers:
Pointers to far objects are stored using four bytes (32 bits). The bytes are stored little endian or low to high order. The first word contains the 14-bit memory offset (bits 14 and 15 are always 0). The second word contains the page number (or segment number for function pointers). The memory address is calculated as follows:

Variable Address = (Page * 0x4000L) + Offset

Function Address = (Segment * 0x10000L) + Offset


 

Answer by c_razy
Submitted on 1/29/2005
Rating: Not yet rated Rate this answer: Vote
far *near int a;
pointer to a object beyond the current segment. the pointer itself resides in the current segment. normally far *int a; etc. normally are always "near far" pointers .
njoy!

 

Answer by anju
Submitted on 6/20/2005
Rating: Not yet rated Rate this answer: Vote
czxcxz

 

Answer by Monu
Submitted on 8/28/2005
Rating: Not yet rated Rate this answer: Vote
In DOS only 1 mb (10,48,580 bytes) of memory is accessible. Any of these memory locations are accessed using CPU registers. Under DOS the CPU registers are only 16 bits long. Therefore, the minimum value present in a CPU register could be 0, and maximum 65,535. Then how do we access memory locations beyond 65535th byte? By using two registers (segment and offset) in conjunction. For this the total memory (1 mb) is divided into a number of units each comprising 65,536 (64 kb) locations. Each such unit is called a segment. Each segment always begins at a location number which is exactly divisible by 16. The segment register contains the address where a segment begins, whereas the offset register contains the offset of the data/code from where the segment begins. For example, let us consider the first byte in B block of video memory. The segment address of video memory is B0000h (20-bit address), whereas the offset value of the first byte in the upper 32K block of this segment is 8000h. Since 8000h is a 16-bit address it can be easily placed in the offset register, but how do we store the 20-bit address B0000h in a 16-bit segment register? For this out of B0000h only first four hex digits (16 bits) are stored in segment register. We can afford to do this because a segment address is always a multiple of 16 and hence always contains a 0 as the last digit. Therefore, the first byte in the upper 32K chunk of B block of video memory is referred using segment:offset format as B000h:8000h. Thus, the offset register works relative to segment register. Using both these, we can point to a specific location anywhere in the 1 mb address space.

Suppose we want to write a character `A' at location B000:8000. We must convert this address into a form which C understands. This is done by simply writing the segment and offset addresses side by side to obtain a 32 bit address. In our example this address would be 0xB0008000. Now whether C would support this 32 bit address or not depends upon the memory model in use. For example, if we are using a large data model (compact, large, huge) the above address is acceptable. This is because in these models all pointers to data are 32 bits long. As against this, if we are using a small data model (tiny, small, medium) the above address won't work since in these models each pointer is 16 bits long.

What if we are working in small data model and still want to access the first byte of the upper 32K chunk of B block of video memory? In such cases both Microsoft C and Turbo C provide a keyword called far

 

Answer by Shri
Submitted on 9/22/2005
Rating: Not yet rated Rate this answer: Vote
near pointer are the one which points to the memory locations in the code segment only.Far pointers are the one which point to memory locations in different segments.

 

Answer by wind
Submitted on 1/4/2006
Rating: Not yet rated Rate this answer: Vote
footballer of England....

 

Answer by ganesh
Submitted on 4/3/2006
Rating: Not yet rated Rate this answer: Vote
what is near & far pointer?

 

Answer by SunnyPalSingh
Submitted on 4/25/2006
Rating: Not yet rated Rate this answer: Vote
In a segmented architecture computer, a far pointer is a pointer which includes a
segment number, making it possible to point to addresses outside of the current segment.

 

Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.


Your name or nickname:
If you'd like to create a new account or access your existing account, put in your password here:
Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

 

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

 

<< Back to: comp.compilers monthly message and Frequently Asked Questions


[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]

© 2008 FAQS.ORG. All rights reserved.