home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / libsrc / c / dos / kbhit.s < prev    next >
Encoding:
Text File  |  1993-08-07  |  1.1 KB  |  52 lines

  1. /* This is file KBHIT.S */
  2. /*
  3. ** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. **
  5. ** This file is distributed under the terms listed in the document
  6. ** "copying.dj", available from DJ Delorie at the address above.
  7. ** A copy of "copying.dj" should accompany this file; if not, a copy
  8. ** should be available from where this file was obtained.  This file
  9. ** may not be distributed without a verbatim copy of "copying.dj".
  10. **
  11. ** This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. */
  14.  
  15.     .globl    _kbhit
  16. _kbhit:
  17.     pushl    %ebp
  18.     movl    %esp,%ebp
  19.     pushl    %ebx
  20.     pushl    %esi
  21.     pushl    %edi
  22.  
  23. try_again:
  24.     movl    $0x41a,%eax
  25.     call    dosmemsetup
  26.     movzwl    %gs:(%eax),%ebx
  27.     movzwl    %gs:2(%eax),%ecx
  28.     cmp    %ebx,%ecx
  29.     je    key_not_hit
  30.  
  31.     movb    $0x11,%ah
  32.     int    $0x16
  33.     jz    key_not_hit
  34.     cmp    $0,%eax
  35.     jne    key_hit
  36.     movb    $0x10,%ah
  37.     int    $0x16
  38.     jmp    try_again
  39.  
  40. key_not_hit:
  41.     movl    $0,%eax
  42.     jmp    L1
  43.  
  44. key_hit:
  45.     movl    $1,%eax
  46. L1:
  47.     popl    %edi
  48.     popl    %esi
  49.     popl    %ebx
  50.     leave
  51.     ret
  52.