ports.pp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. and implements some stuff for protected mode programming
  5. Copyright (c) 1999-2000 by the Free Pascal development team.
  6. These files adds support for TP styled port accesses
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. unit ports;
  14. { this unit uses classes so
  15. ObjFpc mode is required PM }
  16. {$Mode ObjFpc}
  17. interface
  18. type
  19. tport = class
  20. procedure writeport(p : word;data : byte);
  21. function readport(p : word) : byte;
  22. property pp[w : word] : byte read readport write writeport;default;
  23. end;
  24. tportw = class
  25. procedure writeport(p : word;data : word);
  26. function readport(p : word) : word;
  27. property pp[w : word] : word read readport write writeport;default;
  28. end;
  29. tportl = class
  30. procedure writeport(p : word;data : longint);
  31. function readport(p : word) : longint;
  32. property pp[w : word] : longint read readport write writeport;default;
  33. end;
  34. var
  35. { we don't need to initialize port, because neither member
  36. variables nor virtual methods are accessed }
  37. port,
  38. portb : tport;
  39. portw : tportw;
  40. portl : tportl;
  41. implementation
  42. {$asmmode ATT}
  43. { to give easy port access like tp with port[] }
  44. procedure tport.writeport(p : word;data : byte);assembler;
  45. asm
  46. movw p,%dx
  47. movb data,%al
  48. outb %al,%dx
  49. end ['EAX','EDX'];
  50. function tport.readport(p : word) : byte;assembler;
  51. asm
  52. movw p,%dx
  53. inb %dx,%al
  54. end ['EAX','EDX'];
  55. procedure tportw.writeport(p : word;data : word);assembler;
  56. asm
  57. movw p,%dx
  58. movw data,%ax
  59. outw %ax,%dx
  60. end ['EAX','EDX'];
  61. function tportw.readport(p : word) : word;assembler;
  62. asm
  63. movw p,%dx
  64. inw %dx,%ax
  65. end ['EAX','EDX'];
  66. procedure tportl.writeport(p : word;data : longint);assembler;
  67. asm
  68. movw p,%dx
  69. movl data,%eax
  70. outl %eax,%dx
  71. end ['EAX','EDX'];
  72. function tportl.readport(p : word) : longint;assembler;
  73. asm
  74. movw p,%dx
  75. inl %dx,%eax
  76. end ['EAX','EDX'];
  77. end.
  78. {
  79. $Log$
  80. Revision 1.4 2000-02-09 16:59:29 peter
  81. * truncated log
  82. Revision 1.3 2000/01/07 16:41:32 daniel
  83. * copyright 2000
  84. Revision 1.2 2000/01/07 16:32:23 daniel
  85. * copyright 2000 added
  86. Revision 1.1 1999/09/01 14:47:31 pierre
  87. TP port construction separated into this unit
  88. }