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

  1. /*-----------------------------------------------------------------------*
  2.  * filename - outport.cas
  3.  *
  4.  * function(s)
  5.  *        outport  - output word to a hardware port
  6.  *        outportb - output byte to a hardware port
  7.  *        outp     - output byte to a hardware port, return value output
  8.  *        outpw    - output word to a hardware port, return value output
  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 outportb
  24. #undef outport
  25. #undef outp
  26. #undef outpw
  27.  
  28. /*-----------------------------------------------------------------------*
  29.  
  30. Name            outport - output to a hardware port
  31.  
  32. Usage           void outport(unsigned port, unsigned val);
  33.  
  34. Prototype in    dos.h
  35.  
  36. Description     see inport
  37.  
  38. *------------------------------------------------------------------------*/
  39. void outport(unsigned port, unsigned val)
  40. {
  41. asm     mov     dx, port
  42. asm     mov     ax, val
  43. asm     out     dx, ax
  44. }
  45.  
  46. /*-----------------------------------------------------------------------*
  47.  
  48. Name            outportb - output to a hardware port
  49.  
  50. Usage           #include <dos.h>
  51.                 void outportb(unsigned port, unsigned char val);
  52.  
  53. Prototype in    dos.h
  54.  
  55. Description     see inport
  56.  
  57. *------------------------------------------------------------------------*/
  58. void outportb(unsigned port, unsigned char val)
  59. {
  60. asm     mov     dx, port
  61. asm     mov     al, val
  62. asm     out     dx, al
  63. }
  64.  
  65. /*-----------------------------------------------------------------------*
  66.  
  67. Name            outpw   - output word to a hardware port
  68.  
  69. Usage           unsigned outpw(unsigned port, unsigned val);
  70.  
  71. Prototype in    dos.h
  72.  
  73. Description     Similar to outport, except that it returns
  74.                 the value output.  MSC compatible.
  75.  
  76. *------------------------------------------------------------------------*/
  77. unsigned outpw(unsigned port, unsigned val)
  78. {
  79. asm     mov     dx, port
  80. asm     mov     ax, val
  81. asm     out     dx, ax
  82.         return (_AX);
  83. }
  84.  
  85. /*-----------------------------------------------------------------------*
  86.  
  87. Name            outp    - output byte to a hardware port
  88.  
  89. Usage           int outp(unsigned port, int val);
  90.  
  91. Prototype in    dos.h
  92.  
  93. Description     Similar to outportb, except that it returns
  94.                 the value output.  MSC compatible.
  95.  
  96. *------------------------------------------------------------------------*/
  97. int outp(unsigned port, int val)
  98. {
  99. asm     mov     dx, port
  100. asm     mov     al, val
  101. asm     out     dx, al
  102. asm     xor     ah, ah
  103.         return (_AX);
  104. }
  105.