delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2013/03/09/19:30:24

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Rod Pemberton" <do_not_have AT notemailnotq DOT cpm>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: FARPTRGS
Date: Sat, 9 Mar 2013 19:18:40 -0500
Organization: Aioe.org NNTP Server
Lines: 72
Message-ID: <khgjd1$dk3$1@speranza.aioe.org>
References: <4f3c0ea8-ce8b-403f-9d8f-7197e66e4186 AT googlegroups DOT com> <56DBAFDDD8D54E7FA53359A52B14D263 AT dev DOT null>
NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org
X-Complaints-To: abuse AT aioe DOT org
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.2001
X-Notice: Filtered by postfilter v. 0.8.2
X-Newsreader: Microsoft Outlook Express 6.00.2800.2001
X-Priority: 3
X-MSMail-Priority: Normal
Bytes: 2937
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Gisle Vanem" <gvanem AT broadpark DOT no> wrote in message
news:56DBAFDDD8D54E7FA53359A52B14D263 AT dev DOT null...
> <starus2013 AT gmail DOT com> wrote:

> > #include <LIBC\farptrgs.h>
>
> Never use this in app-code. It's for djgpp internal use.
> Do a "#include <sys/farptr.h>" instead. Your use fall
> under the category "undefined behavior".
>
> > int main(){
> > int f,selector;
> >
> > __dpmi_meminfo info;
> >
> >   info.size=1023;
> >   info.address=0x50000;
> >
> >   selector = __dpmi_allocate_ldt_descriptors(1);
> > if(selector == -1) return 0;
> > if(__dpmi_set_segment_base_address(selector,info.address)==-1)
> >   return 0;
> > if(__dpmi_set_segment_limit(selector,info.size-1)==-1)
> >   return 0;
> >
> > _farsetsel(selector);
>
> Read the comment in <sys/farptr.h>:
>
>   Warning: These routines all use the %fs register for their
>   accesses.  GCC normally uses only %ds and %es, and libc
>   functions (movedata, dosmemget, dosmemput) use %gs.  Still,
>   you should be careful about assumptions concerning whether or
>   not the value you put in %fs will be preserved across calls to
>   other functions.  If you guess wrong, your program will crash.
>   Better safe than sorry.
>
> So GS register is in practice reserved for libc internal stuff.
> AFAICR movedata() etc. don't preserve it. Check for yourself.
>
> Also note that real-mode callbacks (RMCB code) doesn't either
> push/pop the FS+GS registers. Your callback should do it if you
> these registers.
>

%gs is used by a bunch of other stuff too...


%cs  _my_cs()
%cs  _go32_my_cs()
%ds  _my_ds()
%ds  _go32_my_ds()
%ss  _my_ss()
%ss  _go32_my_ss()
%es    same as %ds
%fs    used by farpeek(), farpoke()
mirror of %ds  __djgpp_ds_alias
%gs  __djgpp_dos_sel
%gs  _dos_ds
%gs  _go32_info_block.selector_for_linear_memory
%gs  _go32_info_block+26
%gs  _go32_conventional_mem_selector()


You can use _farsetsel to set %fs, e.g., to _dos_ds or _my_ds().
_dos_ds is mapped to the first 1MB plus 64KB.  _my_ds() is the
application data space.  Or, you can enable 'nearptrs'.


Rod Pemberton


- Raw text -


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