bcc_io.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /************************************************************************/
  2. /* This file contains the BCC compiler helper functions */
  3. /* (C) Prentice Hall (Minix) http://www.cs.vu.nl/~ast/minix.html */
  4. /* Miscellaneous obsolete junk
  5. * __inport.o __inportb.o __outport.o __outportb.o __peekb.o __peekw.o
  6. * __pokeb.o __pokew.o
  7. */
  8. #ifdef __AS368_16__
  9. #if !__FIRST_ARG_IN_AX__
  10. #asm
  11. .text ! This is common to all.
  12. .even
  13. #endasm
  14. /************************************************************************/
  15. /* Function inport */
  16. #ifdef L___inport
  17. #asm
  18. ! int inport( int port );
  19. ! reads a word from the i/o port port and returns it
  20. .globl _inport
  21. _inport:
  22. pop bx
  23. pop dx
  24. dec sp
  25. dec sp
  26. inw
  27. jmp bx
  28. #endasm
  29. #endif
  30. /************************************************************************/
  31. /* Function inportb */
  32. #ifdef L___inportb
  33. #asm
  34. ! int inportb( int port );
  35. ! reads a byte from the i/o port port and returns it
  36. .globl _inportb
  37. _inportb:
  38. pop bx
  39. pop dx
  40. dec sp
  41. dec sp
  42. in
  43. sub ah,ah
  44. jmp bx
  45. #endasm
  46. #endif
  47. /************************************************************************/
  48. /* Function outport */
  49. #ifdef L___outport
  50. #asm
  51. ! void outport( int port, int value );
  52. ! writes the word value to the i/o port port
  53. .globl _outport
  54. _outport:
  55. pop bx
  56. pop dx
  57. pop ax
  58. sub sp,*4
  59. outw
  60. jmp bx
  61. #endasm
  62. #endif
  63. /************************************************************************/
  64. /* Function outportb */
  65. #ifdef L___outportb
  66. #asm
  67. ! void oportb( int port, char value );
  68. ! writes the byte value to the i/o port port
  69. ! this would be outportb except for feeble linkers
  70. .globl _oportb
  71. _oportb:
  72. pop bx
  73. pop dx
  74. pop ax
  75. sub sp,*4
  76. out
  77. jmp bx
  78. #endasm
  79. #endif
  80. /************************************************************************/
  81. /* Function peekb */
  82. #ifdef L___peekb
  83. #asm
  84. ! int peekb( unsigned segment, char *offset );
  85. ! returns the (unsigned) byte at the far pointer segment:offset
  86. .define _peekb
  87. _peekb:
  88. mov cx,ds
  89. pop dx
  90. pop ds
  91. pop bx
  92. sub sp,*4
  93. movb al,(bx)
  94. subb ah,ah
  95. mov ds,cx
  96. jmp dx
  97. #endasm
  98. #endif
  99. /************************************************************************/
  100. /* Function peekw */
  101. #ifdef L___peekw
  102. #asm
  103. ! int peekw( unsigned segment, int *offset );
  104. ! returns the word at the far pointer segment:offset
  105. .define _peekw
  106. _peekw:
  107. mov cx,ds
  108. pop dx
  109. pop ds
  110. pop bx
  111. sub sp,*4
  112. mov ax,(bx)
  113. mov ds,cx
  114. jmp dx
  115. #endasm
  116. #endif
  117. /************************************************************************/
  118. /* Function pokeb */
  119. #ifdef L___pokeb
  120. #asm
  121. ! void pokeb( unsigned segment, char *offset, char value );
  122. ! writes the byte value at the far pointer segment:offset
  123. .define _pokeb
  124. _pokeb:
  125. mov cx,ds
  126. pop dx
  127. pop ds
  128. pop bx
  129. pop ax
  130. sub sp,*6
  131. movb (bx),al
  132. mov ds,cx
  133. jmp dx
  134. #endasm
  135. #endif
  136. /************************************************************************/
  137. /* Function pokew */
  138. #ifdef L___pokew
  139. #asm
  140. ! void pokew( unsigned segment, int *offset, int value );
  141. ! writes the word value at the far pointer segment:offset
  142. .define _pokew
  143. _pokew:
  144. mov cx,ds
  145. pop dx
  146. pop ds
  147. pop bx
  148. pop ax
  149. sub sp,*6
  150. mov (bx),ax
  151. mov ds,cx
  152. jmp dx
  153. #endasm
  154. #endif
  155. #endif /* !__FIRST_ARG_IN_AX__ */
  156. #endif