News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Reading a scape key

Started by drjr, July 18, 2007, 12:36:06 AM

Previous topic - Next topic

drjr

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.

ic2

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.

sinsi

NT/2000/XP won't let real mode programs (e.g. DOS stuff) access the ports directly, whereas 95/98/ME did.
Light travels faster than sound, that's why some people seem bright until you hear them.

MichaelW

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.
eschew obfuscation