18.2 Types,constants and variables

Types

The following types are defined to implement the port access.
 tport = class
   protected
     procedure writeport(p : longint;data : byte);
     function  readport(p : longint) : byte;
   public
     property pp[w : longint] : byte read readport write writeport;default;
 end;
 
 tportw = class
   protected
     procedure writeport(p : longint;data : word);
     function  readport(p : longint) : word;
   public
     property pp[w : longint] : word read readport write writeport;default;
 end;
 
 tportl = class
   Protected
     procedure writeport(p : longint;data : longint);
     function  readport(p : longint) : longint;
   Public
    property pp[w : Longint] : longint read readport write writeport;default;
 end;
Each of these types allows access to the ports using respectively, a byte, a word or a longint sized argument.

Since there is a default property for each of this types, a sentence as

   port[221]:=12;
Will result in the byte 12 being written to port 221, if port is defined as a variable of type tport

variables

The following variables are defined:
 port,
 portb : tport;
 portw : tportw;
 portl : tportl;
They allow access to the ports in a Turbo Pascal compatible way.