Mail Archives: djgpp/1997/04/09/17:42:11
> what is the exact difference between far and near pointers ...
Slightly different depending on whether you are in real mode or
protected mode. Sinece you are posting to DJGPP I assume you
mean protected mode but I will try to explain both.
In Real mode memory is addressed using a segment and an offset.
Each is 16 bits. Together they are 32 bits long and a far pointer.
Now, think of a .com program. Everything resides in a single segment in
memory. If you are going to access any memory in your data segment
you know that it will all have the same segment value, and just
different offsets. Therefore, you can store just the 16 bit offset
portions. But, if you want to access video memory directly say, then
you will need to specify a full segment:offset to it. If your program
grows to big for the tiny model, and you need multiple code or data
segments then you need to keep track of both the offsets and segments.
In protected mode you now have selectors instead of segments (still
16 bits though). Offsets are now 32 bits long. In djgpp all
pointers are just the 32 bit offset portion. Some of the far routines
in djgpp use full 48 bit pointers (video memory again say).
I know there is also a near pointer concept in djgpp. I am not sure what it
does exactly (although I assume it allows you to access memory not normally
in your selector with just a 32 bit offset ?)
Andrew
- Raw text -