What are near, far and huge pointers?

Four registers are used to refer to four segments on the 16-bit x86 segmented memory architecture. DS (data segment), CS (code segment), SS (stack segment), and ES (extra segment). A logical address on this platform is written segment:offset, in hexadecimal.

Near pointers refer (as an offset) to the current segment.

Far pointers use segment info and an offset to point across segments. So, to use them, DS or CS must be changed to the specified value, the memory will be dereferenced and then the original value of DS/CS restored. Note that pointer arithmetic on them doesn’t modify the segment portion of the pointer, so overflowing the offset will just wrap it around.

And then there are huge pointers, which are normalized to have the highest possible segment for a given address (contrary to far pointers).

Leave a Reply

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