ports.pp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Michael Van Canneyt
  5. member of the Free Pascal development team
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. Unit ports;
  13. {$mode objfpc}
  14. { Implements the
  15. port[] portw[] and portl[]
  16. constructs using Delphi classes }
  17. Interface
  18. type
  19. tport = class
  20. protected
  21. procedure writeport(p : longint;data : byte);
  22. function readport(p : longint) : byte;
  23. public
  24. property pp[w : longint] : byte read readport write writeport;default;
  25. end;
  26. tportw = class
  27. protected
  28. procedure writeport(p : longint;data : word);
  29. function readport(p : longint) : word;
  30. public
  31. property pp[w : longint] : word read readport write writeport;default;
  32. end;
  33. tportl = class
  34. Protected
  35. procedure writeport(p : longint;data : longint);
  36. function readport(p : longint) : longint;
  37. Public
  38. property pp[w : Longint] : longint read readport write writeport;default;
  39. end;
  40. { Non-Instantiaded vars. As yet, they don't have to be instantiated,
  41. because there is no need for 'self' etc. }
  42. var
  43. port,
  44. portb : tport;
  45. portw : tportw;
  46. portl : tportl;
  47. implementation
  48. uses x86;
  49. { to give easy port access like tp with port[] }
  50. procedure tport.writeport(p : Longint;data : byte);
  51. begin
  52. x86.writeport (p,data)
  53. end;
  54. function tport.readport(p : Longint) : byte;
  55. begin
  56. readport := x86.readportb (p);
  57. end;
  58. procedure tportw.writeport(p : longint;data : word);
  59. begin
  60. x86.writeport (p,data)
  61. end;
  62. function tportw.readport(p : longint) : word;
  63. begin
  64. readport := x86.readportw(p);
  65. end;
  66. procedure tportl.writeport(p : longint;data : longint);
  67. begin
  68. x86.writeport (p,data)
  69. end;
  70. function tportl.readport(p : longint) : longint;
  71. begin
  72. readPort := x86.readportl(p);
  73. end;
  74. end.
  75. $Log$
  76. Revision 1.5 2003-09-20 18:10:28 marco
  77. * More fixes
  78. Revision 1.4 2002/09/07 16:01:27 peter
  79. * old logs removed and tabs fixed
  80. }