From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: HELP! What's the differnce between Far and near pointers? Date: Mon, 9 Feb 1998 19:13:19 +0000 Organization: None Distribution: world Message-ID: References: <6bnh8o$pc3$1 AT madrid DOT visi DOT net> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 25 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Kris Mills writes: >What is the differnce between far and near pointers? I thought that this was >protected mode were the memory was in Flat Mode so all the memory was in one >linear chunk. could so one please explain that to me.. Thanks In a real mode program, a far pointer is a 32 bit value made up from a 16 bit segment and 16 bit offset, which lets you access any memory in the first megabyte. A real mode near pointer is just a 16 bit offset, which can only access locations within a 64k chunk. In protected mode, a near pointer is 32 bits so it can directly access up to 4GB of memory. For a djgpp program this includes all your code, all your variables, and anything that you allocate with library functions like malloc(), ie. all the memory that you will normally need to use. But in some special situations you may want to access specific locations like a conventional memory buffer for communicating with DOS, or the video memory in your graphics card, and those aren't part of your linear address space. The solution is to use a protected mode far pointer, which is a 48 bit value consisting of a 16 bit selector and 32 bit offset, and can be implemented with the functions in . -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ "Pigs use it for a tambourine" - Frank Zappa