delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/17/15:04:36

Message-ID: <F77915E7F086D31197F4009027CC81C91CC519@probe-2.as-london.acclaim.com>
From: Shawn Hargreaves <SHargreaves AT acclaimstudios DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: Help getting around segread
Date: Mon, 17 Jan 2000 18:03:44 -0000
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Reply-To: djgpp AT delorie DOT com

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 -


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