Mail Archives: djgpp/2013/03/08/14:29:37
<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.
--gv
- Raw text -