delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/30/02:32:30

Date: Thu, 29 Jul 1999 11:19:01 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Rock <rock2000 AT ntplx DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Nasm and real-mode ISRs (bimodal)
In-Reply-To: <379e685d.1136020@news.ntplx.com>
Message-ID: <Pine.SUN.3.91.990729111832.25908Q-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 28 Jul 1999, Rock wrote:

> But i've found, from what it looks like, that if I just
> install the protected mode ISR, then not only do I have a problem
> getting my 'default' DS selector, but that even worse is if it is
> called from real-mode, then just about all the selectors are illegal
> real-mode segments  (except cs and, it looks like, gs).

This is correct.  When your ISR is called, the only valid selector is
CS.

> How can I get all the information I need with just that?

All the information you need is stored for you in the convenience
variables that are addressable through the CS selector.  Look at what
the DJGPP wrappers do, and you will see how easy it is done.  For
example, the safe selector to address data is in the variable
__djgpp_ds_alias.  Load DS, ES, and SS with cs:___djgpp_ds_alias, and
you are all set, even if you need to run C code.

> Under Watcom/DOS4GW it never changes any of the selectors (from what
> I've seen). I guess that's an exception though. Watcom sets all the
> selectors to a base address of 0 and length of 4 Gig. Everything is
> accessable and no segment changes are ever done (I realize this loses
> much of the protection, but its soooo much easier.

Easier to wipe your hard disk, you mean ;-).

> I'll try, I didn't see it in the faq, but I'll check again. Is there
> any selectors that aren't used at all I could use to 'save' the needed
> selectors in? I thought fs was unused, but something is setting it to
> 0 (of all numbers) in the program. GS seems to always point to the dos
> low memory selector. Is it safe to always assume that it is untouched?

No selector except CS is safe when you are in an interrupt handler.
FS is untouched by the DJGPP library, but since the ISR is called by
the DPMI handler, all bets are off.  GS is used by the library, so
don't expect it to stay put across library function calls.  And of
course assembly code that you write and run can change anything it
likes, so no promises here, either.

The usual rule in ISR programming is to have every variable you need
to access from the ISR be addressable via CS.  As I said above, DJGPP
provides everything a protected-mode ISR might need in such variables.
Just look in the sources, or ask here.

- Raw text -


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