home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / fortran / mslang / getkey / getkey.asm next >
Assembly Source File  |  1993-06-04  |  3KB  |  79 lines

  1.         .MODEL LARGE
  2.         .CODE
  3.         PUBLIC  CHKKEY
  4.         PUBLIC  GETKEY
  5. CHKKEY  PROC    Far
  6.         push    bp
  7.         mov     bp,sp
  8.         IFDEF   WATCOM
  9.         push    es
  10.         push    si
  11.         mov     es, dx          ; DX is segment of return value
  12.         mov     si, ax          ; AX is offset of return value
  13.         ELSEIFDEF LAHEY
  14.         les     si, [bp+6]      ; Load result addr
  15.         ELSE    ; MSOFT is default
  16.         push    si
  17.         les     si, [bp+6]      ; Load result addr
  18.         ENDIF
  19. ;
  20. ;       Keyboard Status Routine
  21. ;       Copyright 1992 Kenneth G. Hamilton
  22. ;
  23. ;       Call from Lahey, Microsoft or Watcom real mode Fortran with:
  24. ;         CALL CHKKEY(ISTAT)
  25. ;         CALL GETKEY(ISTAT)
  26. ;       where ISTAT is an INTEGER*2 variable.
  27. ;
  28. ;       If CHKKEY was called, then the keyboard will be checked for
  29. ;       input.  If there has been none, then a return with ISTAT=0
  30. ;       is performed.  If a key has been pressed, then the low byte
  31. ;       of ISTAT will contain the ASCII value, while the high byte
  32. ;       will be the scan code, of the the key that was pressed.
  33. ;
  34. ;       If GETKEY was called, then the program will wait for a key
  35. ;       to be pressed, and then return it as described above.
  36. ;
  37.         mov     ah,01           ; Get keyboard status
  38.         int     16h             ; BIOS call
  39.         jnz     L10             ; Got a keystroke
  40.         mov     ax,0            ; No key input,so return zero
  41.         jmp     L20             ; Get out of here
  42. ;
  43. GETKEY  label   far
  44.         push    bp              ; Second entry point
  45.         mov     bp,sp           ; for when we want to wait
  46.         IFDEF   WATCOM
  47.         push    es
  48.         push    si
  49.         mov     es, dx          ; DX is segment of return value
  50.         mov     si, ax          ; AX is offset of return value
  51.         ELSEIFDEF LAHEY
  52.         les     si, [bp+6]      ; Load result addr
  53.         ELSE    ; MSOFT is default
  54.         push    si
  55.         les     si, [bp+6]      ; Load result addr
  56.         ENDIF
  57. ;
  58. L10:    mov     ah,00           ; We have a key: get it
  59.         int     16h             ; BIOS call; key info is put in AX
  60. ;
  61. L20:    mov     es:[si],ax      ; Store the return value
  62. ;
  63.         IFDEF   WATCOM
  64.         pop     si
  65.         pop     es
  66.         pop     bp
  67.         ret
  68.         ELSEIFDEF LAHEY
  69.         pop     bp
  70.         ret
  71.         ELSE    ; MSOFT is default
  72.         pop     si
  73.         pop     bp
  74.         ret     4
  75.         ENDIF
  76. ;
  77. CHKKEY  ENDP
  78.         END
  79.