ports.pp 2.1 KB

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