Mail Archives: djgpp/1999/07/18/04:43:25
On Sun, 18 Jul 1999, Mark wrote:
> _dos_ds is said to be a selector to allow direct access to absolute
> addresses.
No, it only allows access to the first 1MByte+64KB.
> - If so ... Are all _farnspokeb(), _farnspokel(), _farnspeekw() etc. codes
> using that same 'portal' defined once(?) in a porgram with
> _farsetsel(_dos_ds)?
_farsetsel sets the segment to be used by _farnspeek* and _farnspoke*
functions by loading its argument selector into the FS register. You need
to make sure that no code sets the FS register to a different value while
you use _farns* functions.
> - Can I just use the same _dos_ds with all my _farpokeb() accesses to those
> addresses? Or does _my_ds come in here somewhere?
Yes.
Please read the documentation of the _farptr functions in the library
reference manual, I think they explain all this quite well.
> - And what does the DS mean in _dos_ds?
Data Segment.
> If I were to declare:
> int i[100], *ptr;
> ptr=i;
> Is this within my program's segment or is it going to be far?
All your variables declared in a C program do NOT use far pointer, since
the DS register doesn't change during programn's run (well, almost ;-).
> And if I were to declare:
> unsigned char *double_buffer
> double_buffer = (unsigned char *)malloc(320*200);
> This 'double_buffer' is far, right?
No, it is NOT far. All your C variables are in the normal data segment
whose selector is loaded into DS at startup. _farptr functions use
assembly instructions that override the default data segment by
instructing the CPU to use the selector loaded into FS register instead
of the usual DS.
- Raw text -