home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TASMSWAN.ZIP / KEYBOARD.ASM < prev    next >
Assembly Source File  |  1989-07-14  |  1KB  |  55 lines

  1. %TITLE  "Keyboard INPUT routines"
  2.  
  3.     IDEAL
  4.     DOSSEG
  5.     MODEL    small
  6.  
  7.     CODESEG
  8.  
  9.     PUBLIC    KeyWaiting, GetCh
  10.  
  11. %NEWPAGE
  12. ;-----------------------------------------------------------------------
  13. ;  KeyWaiting - checks if a key press is available
  14. ;-----------------------------------------------------------------------
  15. ;    Input:  none
  16. ;    Output:    zf = 0 : (JNZ) Character is waiting to be read
  17. ;        zf = 1 : (JZ) No character is waiting
  18. ;    Registers: none (flags only)
  19. ;-----------------------------------------------------------------------
  20. PROC    KeyWaiting
  21.     push    ax
  22.     mov    ah,1
  23.     int    16h
  24.     pop    ax
  25.     ret
  26. ENDP    KeyWaiting
  27. %NEWPAGE
  28. ;-----------------------------------------------------------------------
  29. ;  GetCh - returns ASCII,control or function key value
  30. ;-----------------------------------------------------------------------
  31. ;    Input:  none
  32. ;    Output:    zf = 0 (ah = 1): (JNZ)  al = ASCII character
  33. ;        zf = 1 (ah = 0): (JZ)   al = ASCII control or function
  34. ;    Registers: ax
  35. ;-----------------------------------------------------------------------
  36. PROC    GetCh
  37.     xor    ah,ah
  38.     int    16h
  39.     or    al,al
  40.     jnz    @@10
  41.     xchg    ah,al
  42.     add    al,32
  43.     jmp    short @@20
  44. @@10:
  45.     xor    ah,ah
  46.     cmp    al,32
  47.     jb    @@20
  48.     inc    ah
  49. @@20:
  50.     or    ah,ah
  51.     ret
  52. ENDP    GetCh
  53.  
  54.     END
  55.