Mail Archives: djgpp/2017/03/28/19:45:04
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 -