Click here to Skip to main content
15,896,330 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
char far *scr;
char far *arr[10];
what is the usage of far in above statements?
Posted
Comments
PIEBALDconsult 4-Jul-15 14:39pm    
"near and far are nonstandard extentions from the world of 16 bit windows/dos.

a 'near' pointer was a 16-bit offset into a region of memory. The regions start address was implicit and dependant on the context.

'far' was a 32-bit pointer consisting of a 16-bit 'selector' that indirectly determined the
start address of the memory region, and a 16-bit offset into that region.
" -- http://www.cplusplus.com/forum/general/12435/
nv3 4-Jul-15 14:55pm    
My 5! Why don't you post it as an answer?
PIEBALDconsult 4-Jul-15 18:10pm    
It's someone else's answer; I just copied it.
[no name] 4-Jul-15 22:18pm    
That would apply to at least half the answers here. It is correct anyhow.
moyna coder 4-Jul-15 15:31pm    
thank u..

1 solution

PIEBALDconsult's answer is quite sufficient. Here's some additional background on far pointers.

DOS originally ran on Intel's 8088 and 8086 processors. These processors had 16 bit registers and a 20 bit address bus (one megabyte). Since the 20 bit address bus was 4 bits more than what a register could hold, banks of up to 64 kilobytes of memory could be selected - on 16 byte boundaries (called paragraphs). Program code, data, and stack could be made separate (medium and large models) or all overlapping (small model).

As long as all of your data - including stack space - fit inside 64 kb, there was no need to mess with far pointers for data. As long as your code also fit inside 64kb, there was no need for far pointers for function pointers.

However, once you made the decision to have separate stack and data space, or data space larger than 64 kb, or your running code outgrew a 64 kb segment, you needed to switch from simple 16 bit near pointers to 32 bit far pointers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900