Pascal is the another language that can program to connect controlling out of computer‘s port, such as Serial Port, RS-232, Parallel Port, Printer Port. Generally, many languages will have function for sending value and reading value from port.

Although, there is no language, it can be programmed to directly connect along port. So, you have to use the function from DLL file for sending the function that send and read value from port of Pascal like the following,

PORT = the function that send value and get value from port as byte.
PORTW = the function that send value and get value from port as word.

If you will set as array, you will get like this,

VAR PORT: ARRAY [0..65535] OF BYTE ;

PORTW: ARRAY [0..65534] OF WORD;

You will see that the function that is used to read and get value at port, will write by the same function, but can get and read value at port by no input and output function like this,
PORT[DATA] := VALUE;

Commanding as byte to port at the address of port in DATA variable by the value inVALUE variable.

BIT: = PORT [STATUS];

Getting value as byte that can be read at the position of port’s address in STATUS variable is kept in BIT. I will try to program used in Pascal that program will be sending and getting value at printer port. Ok let’s begin.


The example of programming Pascal to connect to printer port

CONST DATA = $378; {set Constant of Printer port}
STATUS = DATA + 1;
CONTROL = DATA + 2;
VAR BIT:BYTE;
{set variable as byte}
PORT[DATA] := BIT; {commanding value that is wanted out at Printer port. }
BIT := PORT[STATUS]; {getting value that come from Printer port. }

The same, we can program connecting port, so we have to program to connect Card I/O 8255 that I will explain the principle of using this card many times. then, we will program about LED.

The example of programming Pascal to connect to Card I/O 8255

VAR I,X:BYTE ; {set variable as byte}
TYPE AR_DATA = ARRAY[1..8] OF BYTE ;{set variable the type of array as byte}
CONST PORTA=$0300 ; {set Constant to port’s position A}
PORTB=$0301; { set Constant to port’s position B}
PORTC=$0302; { set Constant to port’s position C}
PORTCONT=$0303; { set Constant to controlling port’s position }
DATA_OUT:AR_DATA=($FE,$FD,$FB,$F7,$EF,$DF,$BF,$7F); {keep value to be used for sending}
BEGIN
PORT[PORTCONT1] : =$80;
{set value of working to controlling port by giving A,B,C as Output}
FOR X := 1 TO 8 DO
BEGIN
PORT[PORTA] :=DATA_OUT[X] ;
{send value to port’s position A by the value in DATA_OUT that the value is arranged in X variable.}
DELAY(200) ; {set value for delaying the time, 200 milliseconds}
END ;
Y := 8 ;
FOR X : =1 TO 8 DO
BEGIN
PORT[PORTA] :=DATA_OUT[Y] ;
{send value to port’s position A by the value in DATA_OUT that is arranged in Y variable.}
DELAY (200) ;{set value for delaying the time, 200 milliseconds.}
Y:Y-1 ; {erase value in Y variable one a time so that will get value that is used in backward array.}
END ;
END.

From the example and explanation, I hope you understand the principles, functions that are used to program in Pascal. Keep practices!

The learning outcome of this article

1) To know function about sending and getting value along computer port.

2) To know setting and using value in variable as array.

3) To know the form of programming of Pascal for PORT () function that can be used both sending and getting value from port.