what is a far pointer
Answer Posted / imran hassan bergi
Near pointers have a size of 2 bytes. They only store the
offset of the address the pointer is referencing. An
address consisting of only an offset has a range of 0 - 64K
bytes starting from the beginning of DGROUP. A near pointer
can be incremented and decremented using arithmetic
operators (+, -, ++, and --) through the entire address
range. Any attempt to increment a near pointer that has a
value of 64K (0xffff) will result in a value of 0. This is
referred to as wrapping the pointer. A corresponding result
can be expected when attempting to decrement a pointer that
contains an address of 0, except the result will be 64K
instead of 0. In addition to being incremented and
decremented, near pointers can be compared to one another
using relational operators ( <, >, ==, >= and <= ). Far
pointers have a size of 4 bytes. They store both the
segment and the offset of the address the pointer is
referencing. A far pointer has an address range of 0 - 1M
bytes. It is important to understand that an addressing
range of 1M does not remove the 640K barrier from the
program. It means that the pointer can address the upper
memory area (641 - 1M) which typically contains video
memory, ROM and anything else that may be loaded high. A
far pointer can be incremented and decremented using
arithmetic operators. When a far pointer is incremented or
decremented ONLY the offset of the pointer is actually
incremented or decremented. The segment is never
incremented by the arithmetic operators. This means that
although a far pointer can address up to 1Mb of memory, it
can only be incremented through 64Kb and the offset will
start at zero again without changing the value of the
segment. This is referred to as "wrapping" the pointer
(e.g. 0F3E:FFFF + 1 = 0F3E:0000). When a far pointer is
decremented from zero it will wrap the other way and become
64K. Far pointers are not unique. It is possible to have
two far memory addresses that have different segments
values and different offset values that address the same
memory location e.g. 0777:2222 has an absolute address of
07770 + 2222 = 09992 and 0999:0002 has an absolute address
of 09990 + 0002 = 09992. When relational operators are used
on far pointers only the offsets are compared. For example:
if we let a = 0777:2222 and let b = 0999:0002 then a == b
would return false because this is equivalent to 2222 ==
0002 which is in fact false. In other words relational
operators will only work on far pointers if the segment
values of the pointers being compared are the same. Huge
pointers have a size of 4 bytes. They store both the
segment and the offset of the address the pointer is
referencing. A huge pointer has an address range of 0 - 1M
bytes. A huge pointer can be incremented and decremented
using arithmetic operators. The only difference between a
far pointer and a huge pointer is that a huge pointer is
normalized by the compiler. A normalized pointer is one
that has as much of the address as possible in the segment,
meaning that the offset is never larger than 15. A huge
pointer is normalized only when pointer arithmetic is
performed on it. It is not normalized when an assignment is
made. You can cause it to be normalized without changing
the value by incrementing and then decrementing it. The
offset must be less than 16 because the segment can
represent any value greater than or equal to 16 (e.g.
Absolute address 0x17 in a normalized form would be
0001:0001. While a far pointer could address the absolute
address 0x17 with 0000:0017, this is not a valid huge
(normalized) pointer because the offset is greater than
0000F.). Huge pointers can also be incremented and
decremented using arithmetic operators, but since they are
normalized they will not wrap like far pointers. Huge
pointers can be reliably used with relational operators
because they are normalized. This works because
normalization of huge pointers insures that every huge
pointer is unique. It is important to understand that huge
pointers are never the default pointer, even in the huge
memory model.
Is This Answer Correct ? | 27 Yes | 5 No |
Post New Answer View All Answers
Which is more efficient, a switch statement or an if else chain?
What is c method?
What is the purpose of realloc()?
Write a program to implement queue.
Do you know the use of fflush() function?
What is the -> in c?
What is extern c used for?
a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if
What is unary operator?
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
Explain main function in c?
main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }
When was c language developed?
cavium networks written test pattern ..
Is a house a shell structure?