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


Please Help Members By Posting Answers For Below Questions

What is the basic structure of c?

547


How many bytes is a struct in c?

714


Is c easy to learn?

550


What is difference between && and & in c?

561


How can I handle floating-point exceptions gracefully?

619






Compare array data type to pointer data type

592


What is structure padding in c?

616


Write a program to check prime number in c programming?

582


What is a loop?

543


Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers

1414


Explain what is the general form of a c program?

616


What are the rules for identifiers in c?

579


What is difference between static and global variable in c?

527


Tell me can the size of an array be declared at runtime?

589


if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0

1433