home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / INPORT.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  1.8 KB  |  65 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - inport.cas
  3.  *
  4.  * function(s)
  5.  *      inport  - inputs from a hardware port
  6.  *      inportb - inputs from a hardware port
  7.  *-----------------------------------------------------------------------*/
  8.  
  9. /*[]------------------------------------------------------------[]*/
  10. /*|                                                              |*/
  11. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  12. /*|                                                              |*/
  13. /*|                                                              |*/
  14. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  15. /*|     All Rights Reserved.                                     |*/
  16. /*|                                                              |*/
  17. /*[]------------------------------------------------------------[]*/
  18.  
  19. #pragma inline
  20. #include <dos.h>
  21.  
  22. #undef inportb
  23.  
  24. /*-----------------------------------------------------------------------*
  25.  
  26. Name        inport - inputs from a hardware port
  27.  
  28. Usage        int inport(int port);
  29.  
  30. Prototype in    dos.h
  31.  
  32. Description    reads a word from the input port specified by port.
  33.  
  34. Return value    return the value read
  35.  
  36. *------------------------------------------------------------------------*/
  37. int inport(int port)
  38. {
  39. asm    mov    dx,port
  40. asm    in    ax,dx
  41.     return _AX;
  42. }
  43.  
  44.  
  45. /*-----------------------------------------------------------------------*
  46.  
  47. Name        inportb - inputs from a hardware port
  48.  
  49. Usage        unsigned char inportb(int port);
  50.  
  51. Prototype in    dos.h
  52.  
  53. Description    reads a byte from the input port specified by port.
  54.  
  55. Return value    return the value read
  56.  
  57. *------------------------------------------------------------------------*/
  58. unsigned char inportb(int port)
  59. {
  60. asm    mov    dx,port
  61. asm    in    al,dx
  62. asm    xor    ah,ah
  63.     return _AX;
  64. }
  65.