ports.tex 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 1997, by Michael Van Canneyt
  5. %
  6. % The FPC documentation is free text; you can redistribute it and/or
  7. % modify it under the terms of the GNU Library General Public License as
  8. % published by the Free Software Foundation; either version 2 of the
  9. % License, or (at your option) any later version.
  10. %
  11. % The FPC Documentation is distributed in the hope that it will be useful,
  12. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. % Library General Public License for more details.
  15. %
  16. % You should have received a copy of the GNU Library General Public
  17. % License along with the FPC documentation; see the file COPYING.LIB. If not,
  18. % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. % Boston, MA 02111-1307, USA.
  20. %
  21. \chapter{The PORTS unit}
  22. \section{Introduction}
  23. The ports unit implements the \var{port} constructs found in \tp.
  24. It uses classes and default array properties to do this.
  25. The unit exists on \linux, \ostwo and \dos. It is implemented only for
  26. compatibility with \tp. It's usage is discouraged, because using ports
  27. is not portable programming, and the operating system may not even allow
  28. it (for instance \windows).
  29. Under \linux, your program must be run as root, or the \var{IOPerm} call
  30. must be set in order to set appropriate permissions on the port access.
  31. \section{Types,constants and variables}
  32. \subsection{Types}
  33. The following types are defined to implement the port access.
  34. \begin{verbatim}
  35. tport = class
  36. protected
  37. procedure writeport(p : longint;data : byte);
  38. function readport(p : longint) : byte;
  39. public
  40. property pp[w : longint] : byte read readport write writeport;default;
  41. end;
  42. tportw = class
  43. protected
  44. procedure writeport(p : longint;data : word);
  45. function readport(p : longint) : word;
  46. public
  47. property pp[w : longint] : word read readport write writeport;default;
  48. end;
  49. tportl = class
  50. Protected
  51. procedure writeport(p : longint;data : longint);
  52. function readport(p : longint) : longint;
  53. Public
  54. property pp[w : Longint] : longint read readport write writeport;default;
  55. end;
  56. \end{verbatim}
  57. Each of these types allows access to the ports using respectively, a byte, a
  58. word or a longint sized argument.
  59. Since there is a default property for each of this types, a sentence as
  60. \begin{verbatim}
  61. port[221]:=12;
  62. \end{verbatim}
  63. Will result in the byte 12 being written to port 221, if port is defined
  64. as a variable of type \var{tport}
  65. \subsection{variables}
  66. The following variables are defined:
  67. \begin{verbatim}
  68. port,
  69. portb : tport;
  70. portw : tportw;
  71. portl : tportl;
  72. \end{verbatim}
  73. They allow access to the ports in a \tp compatible way.