Access to hardware ports

The ports unit implements the port constructs found in Turbo Pascal. It uses classes and default array properties to do this.

The unit exists on linux, os/2 and dos. It is implemented only for compatibility with Turbo Pascal. It's usage is discouraged, because using ports is not portable programming, and the operating system may not even allow it (for instance Windows).

Under linux, your program must be run as root, or the IOPerm call must be set in order to set appropriate permissions on the port access.

Type implemented to support integer-sized port access
The TPort type is implemented specially for access to the ports in a TP compatible manner. There is no need to create an instance of this type: the standard TP variables are instantiated at unit initialization.
Writes an integer of data to a port
Reads an integer of data from a port
Access integer-sized port by port number
Type implemented to support word-sized port access
The TPortW type is implemented specially for access to the ports in a TP compatible manner. There is no need to create an instance of this type: the standard TP variables are instantiated at unit initialization.
Writes a word of data to a port
Reads a word of data from a port
Access word-sized port by port number
Type implemented to support Longint-sized port access
The TPortL type is implemented specially for access to the ports in a TP compatible manner. There is no need to create an instance of this type: the standard TP variables are instantiated at unit initialization.
Writes a Longint of data to a port
Reads a Longint of data from a port
Access Longint-sized port by port number
Provide port access per integer

Default instance of type . Do not free. This variable is initialized in the unit initialization code, and freed at finalization.

Since there is a default property for a variable of this type, a sentence as

port[221]:=12;

Will result in the integer 12 being written to port 221, if port is defined as a variable of type tport

Provide port access per byte

Default instance of type . Do not free. This variable is initialized in the unit initialization code, and freed at finalization.

Since there is a default property for a variable of this type, a sentence as

portb[221]:=12;

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

Provide port access per word

Default instance of type . Do not free. This variable is initialized in the unit initialization code, and freed at finalization.

Since there is a default property for a variable of this type, a sentence as

portb[221]:=12;

Will result in the word 12 being written to port 221, if port is defined as a variable of type tport

Provide port access per longint

Default instance of type . Do not free. This variable is initialized in the unit initialization code, and freed at finalization.

Since there is a default property for a variable of this type, a sentence as

portl[221]:=12;

Will result in the longint 12 being written to port 221, if port is defined as a variable of type tport