x86.pp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. unit x86;
  2. interface
  3. function ReadPortB (Port : Longint): Byte;
  4. function ReadPortW (Port : Longint): Word;
  5. function ReadPortL (Port : Longint): Longint;
  6. Procedure ReadPort (Port : Longint; Var Value : Byte);
  7. Procedure ReadPort (Port : Longint; Var Value : Longint);
  8. Procedure ReadPort (Port : Longint; Var Value : Word);
  9. Procedure ReadPortB (Port : Longint; Var Buf; Count: longint);
  10. Procedure ReadPortL (Port : Longint; Var Buf; Count: longint);
  11. Procedure ReadPortW (Port : Longint; Var Buf; Count: longint);
  12. Procedure WritePort (Port : Longint; Value : Byte);
  13. Procedure WritePort (Port : Longint; Value : Longint);
  14. Procedure WritePort (Port : Longint; Value : Word);
  15. Procedure WritePortB (Port : Longint; Value : Byte);
  16. Procedure WritePortB (Port : Longint; Var Buf; Count: longint);
  17. Procedure WritePortL (Port : Longint; Value : Longint);
  18. Procedure WritePortW (Port : Longint; Value : Word);
  19. Procedure WritePortW (Port : Longint; Var Buf; Count: longint);
  20. Procedure WritePortl (Port : Longint; Var Buf; Count: longint);
  21. implementation
  22. Procedure WritePort (Port : Longint; Value : Byte);
  23. {
  24. Writes 'Value' to port 'Port'
  25. }
  26. begin
  27. asm
  28. movl port,%edx
  29. movb value,%al
  30. outb %al,%dx
  31. end ['EAX','EDX'];
  32. end;
  33. Procedure WritePort (Port : Longint; Value : Word);
  34. {
  35. Writes 'Value' to port 'Port'
  36. }
  37. begin
  38. asm
  39. movl port,%edx
  40. movw value,%ax
  41. outw %ax,%dx
  42. end ['EAX','EDX'];
  43. end;
  44. Procedure WritePort (Port : Longint; Value : Longint);
  45. {
  46. Writes 'Value' to port 'Port'
  47. }
  48. begin
  49. asm
  50. movl port,%edx
  51. movl value,%eax
  52. outl %eax,%dx
  53. end ['EAX','EDX'];
  54. end;
  55. Procedure WritePortB (Port : Longint; Value : Byte);
  56. {
  57. Writes 'Value' to port 'Port'
  58. }
  59. begin
  60. asm
  61. movl port,%edx
  62. movb value,%al
  63. outb %al,%dx
  64. end ['EAX','EDX'];
  65. end;
  66. Procedure WritePortW (Port : Longint; Value : Word);
  67. {
  68. Writes 'Value' to port 'Port'
  69. }
  70. begin
  71. asm
  72. movl port,%edx
  73. movw value,%ax
  74. outw %ax,%dx
  75. end ['EAX','EDX'];
  76. end;
  77. Procedure WritePortL (Port : Longint; Value : Longint);
  78. {
  79. Writes 'Value' to port 'Port'
  80. }
  81. begin
  82. asm
  83. movl port,%edx
  84. movl value,%eax
  85. outl %eax,%dx
  86. end ['EAX','EDX'];
  87. end;
  88. Procedure WritePortl (Port : Longint; Var Buf; Count: longint);
  89. {
  90. Writes 'Count' longints from 'Buf' to Port
  91. }
  92. begin
  93. asm
  94. movl count,%ecx
  95. movl buf,%esi
  96. movl port,%edx
  97. cld
  98. rep
  99. outsl
  100. end ['ECX','ESI','EDX'];
  101. end;
  102. Procedure WritePortW (Port : Longint; Var Buf; Count: longint);
  103. {
  104. Writes 'Count' words from 'Buf' to Port
  105. }
  106. begin
  107. asm
  108. movl count,%ecx
  109. movl buf,%esi
  110. movl port,%edx
  111. cld
  112. rep
  113. outsw
  114. end ['ECX','ESI','EDX'];
  115. end;
  116. Procedure WritePortB (Port : Longint; Var Buf; Count: longint);
  117. {
  118. Writes 'Count' bytes from 'Buf' to Port
  119. }
  120. begin
  121. asm
  122. movl count,%ecx
  123. movl buf,%esi
  124. movl port,%edx
  125. cld
  126. rep
  127. outsb
  128. end ['ECX','ESI','EDX'];
  129. end;
  130. Procedure ReadPort (Port : Longint; Var Value : Byte);
  131. {
  132. Reads 'Value' from port 'Port'
  133. }
  134. begin
  135. asm
  136. movl port,%edx
  137. inb %dx,%al
  138. movl value,%edx
  139. movb %al,(%edx)
  140. end ['EAX','EDX'];
  141. end;
  142. Procedure ReadPort (Port : Longint; Var Value : Word);
  143. {
  144. Reads 'Value' from port 'Port'
  145. }
  146. begin
  147. asm
  148. movl port,%edx
  149. inw %dx,%ax
  150. movl value,%edx
  151. movw %ax,(%edx)
  152. end ['EAX','EDX'];
  153. end;
  154. Procedure ReadPort (Port : Longint; Var Value : Longint);
  155. {
  156. Reads 'Value' from port 'Port'
  157. }
  158. begin
  159. asm
  160. movl port,%edx
  161. inl %dx,%eax
  162. movl value,%edx
  163. movl %eax,(%edx)
  164. end ['EAX','EDX'];
  165. end;
  166. function ReadPortB (Port : Longint): Byte; assembler;
  167. {
  168. Reads a byte from port 'Port'
  169. }
  170. asm
  171. xorl %eax,%eax
  172. movl port,%edx
  173. inb %dx,%al
  174. end ['EAX','EDX'];
  175. function ReadPortW (Port : Longint): Word; assembler;
  176. {
  177. Reads a word from port 'Port'
  178. }
  179. asm
  180. xorl %eax,%eax
  181. movl port,%edx
  182. inw %dx,%ax
  183. end ['EAX','EDX'];
  184. function ReadPortL (Port : Longint): LongInt; assembler;
  185. {
  186. Reads a LongInt from port 'Port'
  187. }
  188. asm
  189. movl port,%edx
  190. inl %dx,%eax
  191. end ['EAX','EDX'];
  192. Procedure ReadPortL (Port : Longint; Var Buf; Count: longint);
  193. {
  194. Reads 'Count' longints from port 'Port' to 'Buf'.
  195. }
  196. begin
  197. asm
  198. movl count,%ecx
  199. movl buf,%edi
  200. movl port,%edx
  201. cld
  202. rep
  203. insl
  204. end ['ECX','EDI','EDX'];
  205. end;
  206. Procedure ReadPortW (Port : Longint; Var Buf; Count: longint);
  207. {
  208. Reads 'Count' words from port 'Port' to 'Buf'.
  209. }
  210. begin
  211. asm
  212. movl count,%ecx
  213. movl buf,%edi
  214. movl port,%edx
  215. cld
  216. rep
  217. insw
  218. end ['ECX','EDI','EDX'];
  219. end;
  220. Procedure ReadPortB (Port : Longint; Var Buf; Count: longint);
  221. {
  222. Reads 'Count' bytes from port 'Port' to 'Buf'.
  223. }
  224. begin
  225. asm
  226. movl count,%ecx
  227. movl buf,%edi
  228. movl port,%edx
  229. cld
  230. rep
  231. insb
  232. end ['ECX','EDI','EDX'];
  233. end;
  234. end.