From: "Anthony.Appleyard" Organization: Materials Science Centre To: DJGPP AT delorie DOT com Date: Mon, 16 Feb 1998 11:07:50 GMT Subject: Re: Hooking interrupt 9 clashing with new types of BIOS? Reply-to: Anthony DOT Appleyard AT umist DOT ac DOT uk Message-ID: <10ABBB35FCB@fs2.mt.umist.ac.uk> Precedence: bulk "Anthony.Appleyard" wrote:- > I wrote in Gnu C++ a program SPATRL which reads the keyboard events directly > by hooking interrupt 9 directly as listed at the end of this message. On a > 486 desktop PC with DOS 6.22 that I bought about 3 years ago SPATRL always > worked OK with no trouble. But on a new laptop with a Pentium in, and on a > new desktop with a Pentium II in, both with DOS 6.22, SPATRL runs OK and on > exit as intended goes duly back to a DOS prompt; but sometimes a few seconds > after returning to DOS it says something like this:- > C:\LIT\DIV\SPATRL>Invalid TSS in RMCB at eip=107f; flags=3002 > eax=01fd0000 ebx=000020d4 ecx=00000000 edx=00022800 esi=00001c18 edi=0001cfe0 > ebp=00000000 esp=0000310c cs=2b ds=3b es=b7 fs=33 gs=0 ss=33 error=00b4 Eli Zaretski replied:- > This usually means that you don't unhook the keyboard interrupt at exit, and > it is left to point into the void. But I did unhook the keyboard interrupt at exit. A.Appleyard wrote:- > What is happening? Is it some new misfeature that has been put into BIOSes? Eli Zaretski replied:- > This seems highly improbable. But WHY do I keep getting this fault on two new PC's with Pentiums in but not on an older PC with a 486 in, all under DOS 6.22? Also, I did not get the fault on an older laptop with DOS 6.00 and a 386 chip. I always specifically unhook interrupt 9 afterwards. I still suspect that there may be something in newer versions of BIOS or of DOS 6.22 which automatically changes interrupt 9's interrupt address as programs are running. Or is this fault caused by running under a Pentium? ------------------------------------------------------- void I9handler() {uns char c,d; c=inportb(0x60); if(c==0xe0) {k_after0xe0=128; return;} d=(c&127)+k_after0xe0; if(c&128) Keydown[d]=0; else {if(!Keydown[d]) Keypressed[d]++; Keydown[d]=1;} k_after0xe0=0;} /*-----*/ int keypressed(uns char c){int i=Keypressed[c]; Keypressed[c]=0; return i;} /*-----*/ /****** After I call this function, the hooking works ******/ void setreadkeys(void H()=I9handler){int i; for(i=0;i<256;i++) Keydown[i]=Keypressed[i]=0; _go32_dpmi_get_protected_mode_interrupt_vector(9,&old_I9handler); new_I9handler.pm_offset=(int)H; new_I9handler.pm_selector=_go32_my_cs(); _go32_dpmi_chain_protected_mode_interrupt_vector(9,&new_I9handler);}; /*-----*//*** The unhooking function. I always call it. I do not omit it ****/ void clearreadkeys(){int i; for(i=0;i<256;i++) Keydown[i]=0; _go32_dpmi_set_protected_mode_interrupt_vector(9, &old_I9handler);}; // use while(typahead()) get_key(); to keep the character buffer empty //