delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/22/09:27:22

Date: Sun, 22 Nov 1998 14:37:49 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: KECSKEMÉTI BALÁZS <balazs AT tiszanet DOT hu>
cc: djgpp AT delorie DOT com
Subject: Re: Q: playing with selectors
In-Reply-To: <736t0v$j6j$1@pollux.matav.net>
Message-ID: <Pine.SUN.3.91.981122143718.17686V-100000@is>
MIME-Version: 1.0
X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by delorie.com id JAA01863
Reply-To: djgpp AT delorie DOT com

On Sat, 21 Nov 1998, KECSKEMÉTI BALÁZS wrote:

> - what kind of selectors do segment registers contain under
> DJGPP?

DS, SS, and ES are set to the data segment;
CS is set to the code segment;
GS is used by library functions to access conventional memory;
FS is unused and is free to be used by you.

> eg. ES contained a selector with base 0 and 4GB limit, FS pointed
> to the video memory (A000h) with 64K limit etc. Does DJGPP offer
> such things?

It does, but you have to set the selectors yourself.  See section
18.4 of the DJGPP FAQ list (v2/faq211b.zip from the same place you get
DJGPP).

> - Let's say that i set up a selector in FS (in an external assembly
> function), which points to A0000h, and has 64K limit. Then, can i
> use FS in other assemby functions? Later, will it contain what i
> have put in it, or some other functions ( like printf ) may change
> FS (or ES/GS)?

FS is not used by any library functions except _farpeekX, _farsetsel
and _farpokeX.  But if you use third-party packages, they could change
FS.

> And if i change FS in my function, will other functions crash?

FS is free to change, but please note that code emitted by GCC assumes
DS=SS=ES, and will crash otherwise.  So if you change one of these
three, be sure to save and restore them before you return.  See also
section 17.4 of the FAQ.

- Raw text -


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