The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: drjr on July 18, 2007, 12:36:06 AM

Title: Reading a scape key
Post by: drjr on July 18, 2007, 12:36:06 AM
If I run the folowing code under the w98 OS the scape key is reading fine:

              mov dx,96  ; keyboard port 60H
              in al,dx           
              cmp eax,1 ; scape key
              jz label1
                     
The same code doesn`t work under Win XP OS. It generate protection fault.
Would soemone say me why ?

Thanks for all the programmers.
Title: Re: Reading a scape key
Post by: ic2 on July 18, 2007, 05:16:35 AM
Looks like mix 16bit and 32...  I don't think Windows can deal with 16bit.  I'm almost 100% sure of that from what little I know about Dos.
Title: Re: Reading a scape key
Post by: sinsi on July 18, 2007, 05:36:38 AM
NT/2000/XP won't let real mode programs (e.g. DOS stuff) access the ports directly, whereas 95/98/ME did.
Title: Re: Reading a scape key
Post by: MichaelW on July 18, 2007, 05:52:06 AM
As part of a DOS app the code should execute without generating a fault (or at least a fault that would be reported) under either version of Windows, but as sinsi stated the code may be prevented from actually accessing the port. As part of a Win32 app, running under Windows 2000, for the in eax,dx I get Unknown Exception, C0000096h. Basically, under Windows these I/O ports are protected, so a normal Win32 app cannot access them. Also, this particular I/O port, like most of the I/O ports on a PC, is an 8-bit port, so in al,dx would make more sense.