delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/18/04:43:25

Date: Sun, 18 Jul 1999 11:40:43 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Mark <rhosts AT bigfoot DOT com>
cc: djgpp AT delorie DOT com, nate AT cartsys DOT com
Subject: Re: 0xA000 plot pixels questions in 13h mode
In-Reply-To: <3.0.1.32.19990718134517.006a72c8@apiitkl.edu.my>
Message-ID: <Pine.SUN.3.91.990718113306.19517W-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019