delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/05/00:40:14

Sender: nate AT cartsys DOT com
Message-ID: <36BA760E.233AD4CC@cartsys.com>
Date: Thu, 04 Feb 1999 20:39:42 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.0.36 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Q: Forcing mode CO80
References: <3 DOT 0 DOT 6 DOT 32 DOT 19990204051602 DOT 008e4920 AT pop DOT netaddress DOT com>
Reply-To: djgpp AT delorie DOT com

Paul Derbyshire wrote:
> 
> At 05:14 PM 2/2/99 -0800, you wrote:
> >#include <dpmi.h>
> >
> >void set_mode(int m)
> >{
> >  __dpmi_regs r;
> >  r.h.ah = 0;
> >  r.h.al = m;
> >  __dpmi_int(0x10, &r);
> >}
> >
> >int get_mode(void)
> >{
> >  __dpmi_regs r;
> >  r.h.ah = 0x0f;
> >  __dpmi_int(0x10, &r);
> >  return r.h.al;
> >}
> 
> Thanks again. I tested the code and it works perfectly. I wrote a test
> applet that got the current mode, set mode 13h, then restored the original
> mode, reporting info on each step and waiting for a keypress at each step.
> 
> One question. How does one tell if the mode could not be set? the set_mode
> you supplied doesn't appear to do any specific error checking, and it
> doesn't return anything. I'd like to know how to modify the set_mode to
> detect an error, which presumably would mean the mode requested isn't
> available on the hardware.
> 
> Your set_mode passes the ADDRESS of a struct to __dpmi_int(), so I'd guess
> that something in the struct is changed to reflect the error/success status
> of the function. So checking some property of r should be done, I'd guess.
> Or possibly checking the return code of __dpmi_int(), which is specified as
> returning an int.

That would only apply if the interrupt itself went awry, which shouldn't
ever happen.  Actually, I'm not sure how you detect if the mode set
failed-- RBIL doesn't seem to say.  Perhaps the carry flag will be set
(bit 0 of EFLAGS)-- that seems to be a standard way to indicate errors. 
Try something impossible like 0xff and see what happens.
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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