[comp.os.msdos.programmer] Key Checking on a PS/2 Model 25

davidjl@eecs.cs.pdx.edu (David J Leitko) (03/22/91)

I am working on a program that needs to be able to do keychecks very
quickly.  Since, I'm timing very short events, I have disabled
interrupts, and have been using direct port reads to check for
keypresses.  I'd rather not have to resort to interrupts.

Unfortunately, the methods I have been using do not work with the
PS/2 Model 25, and maybe other computers as well.

Does anybody have any suggestions on how this can be accomplished
on a PS/2?

As a second question, does anybody have an up to date listing of
all the possible setting of the Model/SubModel information located
in F000:FFFE?  The latest version I have is from "The _New_ Peter
Norton Programmer's Guide to the IBM PC & PS/2", page 64.  Any 
additional information would be greatly appreciated.

I am enclosing a sample program to demonstrate what I am trying to
do.  Note that this is not the code I need a solution for, it just
demonstrates what I'm doing for key checks now.  This code works
on PCs, XTs, and ATs.  IT WILL LOCK UP ON A PS/2 MODEL 25.  (This 
is written for TASM...)

--
  DOSSEG
  .MODEL SMALL
  .STACK 100h
  .DATA
    KeyMsg       DB  'Key Pressed', 13, 10, '$'
    NotFoundMsg  DB  'System not recognized', 13, 10, '$'
    KEYBOARD     EQU 060h
    NO_KEY       EQU 09Ch
  .CODE
    MOV  AX, @DATA
    MOV  DS, AX

    CLI

    MOV  AX, 0F000h               ; Figure out the machine model
    MOV  ES, AX
    MOV  BH, ES:0FFFEh

TOP_OF_LOOP:

    CMP  BH, 0FEh
    JGE  PC_XT_TEST

    CMP  BH, 0FCh
    JE   AT_TEST

    CMP  BH, 0FAh
    JE   PS2_TEST

NOT_FOUND:
    MOV  AH, 9                    ; System not recognized
    MOV  DX, OFFSET NotFoundMsg
    INT  21h

    STI

    MOV  AH, 04Ch                 ; Clean exit to DOS
    INT  21h

PC_XT_TEST:
    IN   AL, KEYBOARD             ; Quick and dirty..  PC/XT only
    AND  AL, 00010000b
    JNZ  KEY_PRESSED
    JMP  TOP_OF_LOOP

AT_TEST:
    IN   AL, KEYBOARD             ; Quick and dirty..  seems to work
    CMP  AL, NO_KEY               ;   on most systems..  other than
    JNZ  KEY_PRESSED              ;   PC, XT, or PS/2 Model 25
    JMP  TOP_OF_LOOP

PS2_TEST:
    <PLEASE HELP ME!>             ; Can't get anything to work right

    JMP  TOP_OF_LOOP

KEY_PRESSED:
    MOV  AH, 9                    ; Display success
    MOV  DX, OFFSET KeyMsg
    INT  21h

    STI

    MOV  AH, 04Ch                 ; Clean exit to DOS
    INT  21h

  END
--

Thanks for any help you might provide.
--
  David J Leitko                 "Bleah!..."         davidjl@eecs.cs.pdx.edu
  Computer Science Department             ..!uunet!tektronix!pdxgate!davidjl
  Portland State University
  Portland, Oregon                      This space intentionally left blank.