home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 5.ddi / CLIBSRC2.ZIP / INPORT.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  2.7 KB  |  111 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - inport.cas
  3.  *
  4.  * function(s)
  5.  *        inport  - inputs word from a hardware port
  6.  *        inportb - inputs byte from a hardware port
  7.  *        inp     - inputs byte from a hardware port
  8.  *        inpw    - inputs word from a hardware port
  9.  *-----------------------------------------------------------------------*/
  10.  
  11. /*
  12.  *      C/C++ Run Time Library - Version 5.0
  13.  *
  14.  *      Copyright (c) 1987, 1992 by Borland International
  15.  *      All Rights Reserved.
  16.  *
  17.  */
  18.  
  19.  
  20. #pragma inline
  21. #include <dos.h>
  22.  
  23. #undef inportb
  24. #undef inport
  25. #undef inp
  26. #undef inpw
  27.  
  28. /*-----------------------------------------------------------------------*
  29.  
  30. Name            inport - inputs from a hardware port
  31.  
  32. Usage           unsigned inport(unsigned port);
  33.  
  34. Prototype in    dos.h
  35.  
  36. Description     reads a word from the input port specified by port.
  37.  
  38. Return value    return the value read
  39.  
  40. *------------------------------------------------------------------------*/
  41. unsigned inport(unsigned port)
  42. {
  43. asm     mov     dx,port
  44. asm     in      ax,dx
  45.         return _AX;
  46. }
  47.  
  48. /*-----------------------------------------------------------------------*
  49.  
  50. Name            inportb - inputs from a hardware port
  51.  
  52. Usage           unsigned char inportb(unsigned port);
  53.  
  54. Prototype in    dos.h
  55.  
  56. Description     reads a byte from the input port specified by port.
  57.  
  58. Return value    return the value read
  59.  
  60. *------------------------------------------------------------------------*/
  61. unsigned char inportb(unsigned port)
  62. {
  63. asm     mov     dx,port
  64. asm     in      al,dx
  65. asm     xor     ah,ah
  66.         return _AX;
  67. }
  68.  
  69. /*-----------------------------------------------------------------------*
  70.  
  71. Name            inpw - inputs word from a hardware port
  72.  
  73. Usage           unsigned inpw(unsigned port);
  74.  
  75. Prototype in    dos.h
  76.  
  77. Description     reads a word from the input port specified by port.
  78.                 MSC-compatible.
  79.  
  80. Return value    return the value read
  81.  
  82. *------------------------------------------------------------------------*/
  83. unsigned inpw(unsigned port)
  84. {
  85. asm     mov     dx,port
  86. asm     in      ax,dx
  87.         return _AX;
  88. }
  89.  
  90. /*-----------------------------------------------------------------------*
  91.  
  92. Name            inp - inputs from a hardware port
  93.  
  94. Usage           int inp(unsigned port);
  95.  
  96. Prototype in    dos.h
  97.  
  98. Description     reads a byte from the input port specified by port.
  99.                 MSC-compatible.
  100.  
  101. Return value    return the value read
  102.  
  103. *------------------------------------------------------------------------*/
  104. int inp(unsigned port)
  105. {
  106. asm     mov     dx,port
  107. asm     in      al,dx
  108. asm     xor     ah,ah
  109.         return _AX;
  110. }
  111.