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