X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII; format=flowed; reply-type=original Message-id: <56DBAFDDD8D54E7FA53359A52B14D263@dev.null> From: Gisle Vanem To: djgpp References: <4f3c0ea8-ce8b-403f-9d8f-7197e66e4186 AT googlegroups DOT com> Subject: Re: FARPTRGS Date: Fri, 08 Mar 2013 19:28:56 +0100 X-Priority: 3 X-MSMail-priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Reply-To: djgpp AT delorie DOT com wrote: > #include Never use this in app-code. It's for djgpp internal use. Do a "#include " 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 : 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. --gv