what are far pointers?
Answer / abhijeet kankani
A near pointer is a 16 bit pointer to an object contained in
the current segment, be it code segment, data segment, stack
segment, or extra segment. The compiler can generate code
with a near pointer and does not have to concern itself with
segment addressing, so using near pointers is fastest, and
generates smallest code. The limitation is that you can only
access 64kb of data at a time, because that is the size of a
segment - 64kb. A near pointer contains only the 16 bit
offset of the object within the currently selected segment.
A far pointer is a 32 bit pointer to an object anywhere in
memory. In order to use it, the compiler must allocate a
segment register, load it with the segment portion of the
pointer, and then reference memory using the offset portion
of the pointer relative to the newly loaded segment
register. This takes extra instructions and extra time, so
it is the slowest and largest method of accessing memory,
but it can access memory that is larger than 64kb,
sometimes, such as when dealing with video memory, a needful
thing. A far pointer contains a 16 bit segment part and a 16
bit offset part. Still, at any one instant of time, without
"touching" segment registers, the program only has access to
four 64kb chunks, or segments of memory. If there is a 100kb
object involved, code will need to be written to consider
its segmentation, even with far pointers.
Now, segments overlap. Each segment is 64kb in length, but
each one overlaps the next and the prior by 65520 bytes.
That means that every address in memory can be addressed by
64kb-1 different combinations of segment:offset pairs. The
result is that the total addressible memory was only 1mb,
and the total usable memory address space was 500kb to
600kb. That sounds odd, but Intel built it, Microsoft wrote
it, and DOS/Windows 3.1 grew up around it. I still have that
computer, and it still works just fine, thank you. :-)>
Now the huge pointer. The far pointer suffers because you
can not just add one to it and have it point the the next
item in memory - you have to consider segment:offset rules,
because of the 16 byte offset issue. The huge pointer is a
monolithic pointer to some item with a large chunk of
memory, and there are no segment:offset boundaries.
Beautiful - huhh?? - well, in order to get that, the pointer
to segment:offset calculation has to be done every time you
reference the pointer. It does allow you to create and
manipulate a single monolithic object that is greater than
64kb, but it has its costs.
| Is This Answer Correct ? | 5 Yes | 0 No |
What is the use of void pointer and null pointer in c language?
difference between semaphores and mutex?
Is the exit() function same as the return statement? Explain.
0 Answers Agilent, ZS Associates,
Write a program which returns the first non repetitive character in the string?
what is meant by flushll() in c programming?
Do you know the difference between exit() and _exit() function in c?
Is double link list a linear data structure? If Yes, Why?If No, Why?
Can I initialize unions?
please help me.. how to write a code of this output?? "Enter range number:"10 1 is an odd number 2 is an even numbers 3 in an odd numbers 4 " to 10" "printing all odd numbers:" 1,3,5,7,9 "printing all even numbers:" 2,4,6,8,10 "sum of all odd numbers:25 "sum of all even numbers:30 using a C Programming ARRAY pleas pleas help.. its my project ..please :(
can we access one file to one directory?
What is function pointer and where we will use it
we have a 3litres jug and a 5 litres jug and no measures on them. using these two jugs how can we measure 4 litres of water?