home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CASM.ARJ / BIOS.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-05-08  |  1.1 KB  |  48 lines

  1. ;_ bios.asm   Sun May  8 1988   Modified by: Walter Bright */
  2.  
  3. include    macros.asm
  4.  
  5.     begcode    bios
  6.  
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8. ; Access BIOS keyboard function
  9. ;    #include <bios.h>
  10. ;    int _bios_keybrd(int flag);
  11. ;    int bioskey(int flag);        /* both are the same routine    */
  12. ; Usage:
  13. ;    flag = 0    Return ascii value in low byte, scan code in high byte
  14. ;         = 1    Return 0 if no key is available else return ascii
  15. ;            value in low byte and scan code in high byte. Key is
  16. ;            left unread in BIOS
  17. ;         = 2    Return shift status, bits are:
  18. ;            0x01    Right shift key is down
  19. ;            0x02    Left shift key is down
  20. ;            0x04    Ctrl key is down
  21. ;            0x08    Alt key is down
  22. ;            0x10    Scroll Lock is toggled
  23. ;            0x20    Num Lock is toggled
  24. ;            0x40    Caps Lock is toggled
  25. ;            0x80    Ins is toggled
  26. ;            Other bits are undefined
  27.  
  28.     public    _bioskey
  29. _bioskey:
  30.  
  31.     c_public _bios_keybrd
  32. func    _bios_keybrd
  33.     push    BP
  34.     mov    BP,SP
  35.     mov    AH,P[BP]
  36.     int    16h
  37.     jnz    K1
  38.     .if    <byte ptr P[BP]> ne 1, K1
  39.     clr    AX        ;if flag is 1 and Z was set
  40. K1:    pop    BP
  41.     ret
  42.  
  43. c_endp    _bios_keybrd
  44.  
  45.     endcode bios
  46.  
  47.     end
  48.