X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: Rod Pemberton 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: <83r31h769s DOT fsf AT gnu DOT org> NNTP-Posting-Host: ZTD62cW/Uw8bymX5ok+0NA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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]" wrote: > On 28 March 2017 at 17:47, Eli Zaretskii (eliz AT gnu DOT org) [via > 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]" > >> > >> > >> 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 > > and ; 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.