delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2017/03/28/19:45:04

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Rod Pemberton <NeedNotReplyHere AT xrsevnneqk DOT cem>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: using fs/gs segment registers in djgpp?
Date: Tue, 28 Mar 2017 19:36:14 -0400
Organization: Aioe.org NNTP Server
Lines: 55
Message-ID: <20170328193614.37e9cf8d@_>
References: <ec865326-58ac-4534-a150-01a09c4e2798 AT googlegroups DOT com>
<83r31h769s DOT fsf AT gnu DOT org>
<CAPLG5jZx4v-0QV+6F5xLALeQHGGiz2RUzkF3eOcYX7Y2MkiJGQ AT mail DOT gmail DOT com>
NNTP-Posting-Host: ZTD62cW/Uw8bymX5ok+0NA.user.gioia.aioe.org
Mime-Version: 1.0
X-Complaints-To: abuse AT aioe DOT org
X-Notice: Filtered by postfilter v. 0.8.2
Bytes: 2835
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Tue, 28 Mar 2017 18:47:06 +0200
"J.W. Jagersma (jwjagersma AT gmail DOT com) [via djgpp AT delorie DOT com]"
<djgpp AT delorie DOT com> wrote:

> On 28 March 2017 at 17:47, Eli Zaretskii (eliz AT gnu DOT org) [via
> djgpp AT delorie DOT com] <djgpp AT delorie DOT com> wrote:

[Please bottom post when posting to Usenet groups.  Reply fixed.]

> >> Date: Tue, 28 Mar 2017 08:19:11 -0700 (PDT)
> >> From: "jwjagersma AT gmail DOT com [via djgpp AT delorie DOT com]"
> >> <djgpp AT delorie DOT com>
> >>
> >> I was wondering if gcc/djgpp ever uses the fs and gs registers.
> >> From disassembling a djgpp-compiled exe, I found some references
> >> to fs (no idea what's stored there though) but gs appears unused.  
> >
> > Both are used, although FS is used more frequently.  See
> > <sys/farptr.h> and <libc/farptrgs.h>; the latter is specifically for
> > code internal to the library.  
>
> Thanks. So as long as I avoid using those headers, gs/fs are safe to
> use? (can't use them anyway since I'm on -masm=intel)
> The farptrgs.h header mentions movedata(), dosmemget() and dosmemput()
> all use gs, but I don't see any of that in the disassembly. Really the
> only functions that appear to use the extra segment registers are
> dos_alloc_ok() and start(), and those only access fs.
> 

My notes say 'fs' is used for far pointers with farpeek() and
farpoke(), whereas 'gs' is used for a bunch of things behind the
scenes in DJGPP:

__djgpp_dos_sel
_dos_ds
_go32_info_block.selector_for_linear_memory
_go32_info_block+26
_go32_conventional_mem_selector()


Of course, neither is safe in the sense that they are unused or free
to use.  So, I would say 'fs' is "safe" to use since you can save,
restore, and set 'fs' using __fargetsel() and __farsetsel(), but (IIRC)
there is no method to save and restore 'gs' in DJGPP without resorting
to inlined assembly.


HTH,


Rod Pemberton
-- 
All it takes for humanity to conquer the world's toughest problems
is to hope, to believe, to share, and to do, in cooperation.

- Raw text -


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