Question

I have seen many time that far pointers are used to work for TSR. Why these TSR program need far pointers and why these are considered harmful for general machine.

Was it helpful?

Solution

Since a TSR program has to share an address space that is not guarantee to stay in a single segment, a far address ( ie containing both segmant:address ) coordinates is required to identify a pointer. This is a little historical since as far as I know it make sense just under DOS.

OTHER TIPS

A far pointer consists of two parts, a segment selector and an offset.

One problem with segmented addressing in general (which is only applicable in 16-bit real mode, unlike 32 bit protected mode which post-DOS computers use) is that a single location in physical memory can be accessed from multiple 'far pointers'. (Which is why it is discouraged in normal 16-bit coding)

The example given from wikipedia is valid.

char far *p =(char far *)0x55550005;
char far *q =(char far *)0x53332225;

Both point to address 0x55555. Source: http://en.wikipedia.org/wiki/Far_pointer

When a program is executing, it does not always need to specify a segment offset (it can use a near pointer), this is because the memory segment it is using is already selected.

In relation to TSR programs, a completely different program is executing when control must be transferred back to the original program. The original program has no way of knowing what the currently selected segment is, so must provide a full 'far pointer' containing both segment and offset. http://en.wikipedia.org/wiki/Terminate_and_Stay_Resident

Note also http://en.wikipedia.org/wiki/X86_memory_segmentation

Who says they are harmful? They just need more space than others, and thus were discouraged in the old days. Besides, the segment registers had to be changed for using them.

If you elaborate about where they are used in a TSR, I might be able to tell more.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top