Mail Archives: djgpp/2000/01/17/15:04:36
Michael writes:
> I understand that DJGPP uses the _my_cs, _my_ds, and
> _my_ss functions for the same purpose as segread but
> I have no idea how to implement them.
You just call whichever function you want, and it returns
the appropriate value. ie. instead of calling segread(&s)
and then looking up the value of s.cs, you can just use
_my_cs() directly instead.
If you absolutely need a segread() replacement, it can be
written quite easily in asm, eg. this version from the
Allegro vbeafex.c file (but see comments below).
/* my_segread:
* Reads the current selector values.
*/
static void my_segread(SCITECH_SREGS *sregs)
{
#ifdef ALLEGRO_GCC
/* use gcc-style inline asm */
asm (
" movw %%cs, %w0 ; "
" movw %%ds, %w1 ; "
" movw %%es, %w2 ; "
" movw %%fs, %w3 ; "
" movw %%gs, %w4 ; "
" movw %%ss, %w5 ; "
: "=m" (sregs->cs),
"=m" (sregs->ds),
"=m" (sregs->es),
"=m" (sregs->fs),
"=m" (sregs->gs),
"=m" (sregs->ss)
);
#elif defined WATCOM
segread((struct SREGS *)sregs);
#endif
}
> My program won't compile because it states that segread is
> undefined.
If you are trying to port code from another compiler, be warned
that segread() almost certainly doesn't do what you want or
expect. Protected mode systems like djgpp require special steps
when you are calling real mode DOS services, and segread() is
not generally useful for this. The djgpp FAQ has quite a bit
of information about how to issue real mode calls, or if you
ask more specific questions about whatever it is that you are
needing to do here, I'm sure someone will be able to give you
the specifics of how to do that using djgpp.
Shawn Hargreaves.
- Raw text -