Definition: A far pointer in segmented architecture computer is a pointer which includes segment number to address the entire 1mb memory which is available under Dos.
example: int main() {
int a; a=10; printf("%d",&a); return 0;
} Explanation:
When this code is saved/compiled the processor allocates a small amount of memory and memor address is given between the memory range 0 to 65,535.Which is part of the 1mb dos memory ie(10,48,780)bytes.If you want to store data/code beyond the memory range and any where in that 1mb memory.You can do that using the far pointers.By declaring a varible as 'far'pointer.The compiler tells the processor to allocate memory for that specific data/code to perform a specific process in that specific address.The address which is exceeds the 65,535 memory range if referred using the 4 digit hexadecimal number,using the two cpu registers namely segment,offset. While referring to memory address greater than 65,535,the 1mb dos memory is divided into segments,Each segment containing 0 to 65,535 locations(64kb) and to refer these segments the segment register is used.The offset regsiter is used to refer the 65,535 locations present in each segment. So using these two registers(segment:offset)we can refer the entire 1mb memory avialable in Dos.And it is done by writing the segment and offset address side by side like this B8000000.The first four hexadecimal digit represents the segment address and the last four hexadecimal address represents the offset address.
Generally the memory is protected by operating system by segmenting it into segments . The whole application which runs on ones system is in user space and the remaining system resources are put in low memory. The Far pointer is the mechanism to manipulate such a memory , but be cautius it being a praise to make some system resources can still make adverse effects. For an example for address space provided to user : A pointer holding address 1000 is not absolute 1000 but it is some base segment address +1000 say 8000+1000=9000. Because that area is running some usual system characteristics like display memory, keyboard buffer and other. But it is the power of C that lets you to write system routines and low level routines directly manipulating system area. For example: char far*vi; vi=(char far*)0xb8000000L; // Start here to write video buffer And this is possible because u are able access that top segment, Not in relative space but on real or absolute space. Thats it but forget the phenomenon to do things so easily the operating system traps are there.
hope this helps
2006-08-10 23:41:14
·
answer #1
·
answered by Devil M 5
·
0⤊
0⤋
Subbu
Far pointer = A far pointer is, in a Segmented architecture computer, a pointer which includes a segment number, making it possible to point to addresses outside of the current segment.
Pointer is a data structure.
Which used to initialize the memory at runtime, the size may be vary from our usage. but if we are using the array its fixed.
According to my knowledge far pointers are mainly used to build I/O commands.Such as you can write "printf" function by useing far pointer
void main() { char far *vdu=0xB8000000; *(vdu+2)='a'; }
If you run this program in C,you can see "a" in the DOS screen.
Pointer ia a variable holding the address of another varible. So the way to access a varible is done in two ways: * first is simply by the name of varible , * Second is by using the pointer of that varible. Every pointer variable takes a limited space (2 or 4 bytes) according to the machine used. But the limitation is that how much long address we can put in that pointer. Far pointer are giving the more space (bytes) to store the address, so by using far pointer we can address a large address space.
2006-08-10 23:38:16
·
answer #2
·
answered by Joe_Young 6
·
0⤊
0⤋
there is a near pointer which is of two bytes(or half word) means it can address 65535 locations , A far pointer is of four bytes (or a word length) it can address 2^32 locations (in 32 bit system).
pointers are used to store memory address, usuall used in C/C++ or by system level programming. all high level languages use pointers at lower level internally to keep track of memory locations containing data.
2006-08-10 23:37:15
·
answer #3
·
answered by i.i 1
·
0⤊
0⤋
i dont know !
2006-08-10 23:34:36
·
answer #4
·
answered by alex_rock guy 2
·
0⤊
0⤋