Monday, September 16, 2013

Lets know about far, near and huge pointers for fresher interview purpose



All of these three candidates relate to 16 bit architecture where segmented memory architecture was there. They are not at all relevant for present days 32 or 64 bit architecture where the way of memory segmentation is completely different; even they may not exist at all.

Still I believe they are good to learn at least for interview purposes. Here I will give you very basic idea of this and I will not encourage you to go beyond that

In 16 bit architecture, the memory is divided into four segments. Data, Code, Stack and Extra and any logical address in this model has two components selector and offset. Selector is used to select the one out of four logical segments and the offset is used to point the address within the segment as specified by the selector.

On this background, a far pointer (designated by a non standard keyword “far”) can point across the segment as the selector portion of its logical address is explicitly represented. The offset represent the distance from the base of the selector. The arithmetic operations on the far pointers are not allowed to change selector portion, only the offset portion can be changed.

On the other hand, a near pointer can point only to the current segment, hence it has got no explicit selector, only the offset value is there and it is free to be changed through pointer arithmetic.

A huge pointer is like far pointer where explicit selectors are there, but the point of its difference with far pointer is that it is normalized. This means, as pointer arithmetic (in both the cases of far and huge) can change the offset part; it may go beyond the current selector range. In case of far pointer even if the offset is changed to different selector, selector will not be changed, but in case of huge pointer, the selector will be changed to wrap around the offset value, and the offset value will be minimum. This wrapping off selector portion is called pointer normalization.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.