How do far pointers differ from huge pointers?

Ans: It may happen that far pointers holding different addresses may refer to the same memory location. This deduces from the method of obtaining the 20-bit physical address from the segment:offset pair. This is shown below for three different addresses:

Consider the three addresses: 0×00000120, 0×00100020 and 0×00120000

00000 segment address left shifted by 4 bits
0120 offset address
———-
00120 resultant 20-bit address

00100 segment address left shifted by 4 bits
0020 offset address
———-
00120 resultant 20-bit address

00120 segment address left shifted by 4 bits
0000 offset address
———-
00120 resultant 20-bit address

Unlike far pointers huge pointers are ‘normalized’ to avoid these problems. A normalized pointer is a 32- bit pointer, which has as much of its value in the segment address as possible. Since a segment can start every 16 bytes, this means that the offset will only have a value from 0 to F.

To normalize a pointer, first it is converted to its 20-bit address then the left 16 bits are used for the segment address and the right 4 bits for the offset address. For example, given the pointer 500D:9407, converting it to a 20-bit absolute address gives 594D7, which is then normalized to 594D:0007.

huge
pointers are always kept normalized. As a result for any given memory address there is only one possible huge address—segment:offset pair—for it. This is more logical than the result obtained while using far pointers.

But then there is a price to be paid for using huge pointers. Huge pointer arithmetic is done with calls to special subroutines. Because of this, huge pointer arithmetic is significantly slower than that of far or near pointers.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>