home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
PASTUT34
/
COMPORT.TXT
< prev
next >
Wrap
Text File
|
1993-06-12
|
5KB
|
141 lines
DIRECT MEMORY AND PORT ACCESS AND COMMUNICATION.
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Memory access.
══════════════
Mem {byte} )
MemW {word} ) are used to directly access memory.
MemL {longint} )
e.g. Mem[$0040:$0049] := 7;
stores the value 7 in the byte of memory at $0040:$0049.
Data := MemW[Seg(V):Ofs(V)];
moves the word value stored in the first two bytes of the
variable V into the variable Data.
MemLong := MemL[64:3*4];
MemLong variable takes the value stored at $0040:$000C.
Port access.
════════════
Port {byte} ) are one-dimensional arrays, each element
) representing a data port, whose port address
PortW {word} ) corresponds to its index.
When a value is assigned to a component of Port or PortW, the value is
sent as output to the selected port.
When a component of Port or PortW is referenced in an expression, its
value is received as input from the selected port.
e.g. port[data_port_low] := low_order_byte;
where data_port_low and low_order_byte have been previously evaluated.
test := port[data_port_low + 2] div 128;
Communication.
══════════════
A Unit called 'AuxInOut' implements a text file device driver for the
communication ports (serial) of an IBM PC. This unit is shown on pages
213-5 of the Reference Guide (version 5.5) and itself uses procedures
and functions which call short 'in-line' machine code. This unit also
uses the DOS unit, which defines TestRec used by AuxInOut.
The inline machine code procedures and functions use the four BIOS
interrupts $14/$00, $14/$01, $14/$02 and $14/$03 (see pages 38-40 of 'DOS
and BIOS Functions' (Que Corporation).
Interrupt $14/$00, Initialize Communications Port, requires that the AL
register contains a parameter evaluated as follows:
Bits 7,6,5 Bits 4,3 Bit2 Bits 1,0
Baud rate Parity Stop bits Word length
--------- ------- ---------- ------------
000 = 110 baud x0 = none 0 = 1 bit 10 = 7 bits
001 = 150 01 = odd 1 = 2 bits 11 = 8 bits
010 = 300 10 = none
011 = 600 11 = even
100 = 1200
101 = 2400
110 = 4800
111 = 9600
The following program uses the AuxInOut unit to write a string to one of
the communication ports. Through the AssignAux procedure, the Com1 file is
associated with the COM1 port, because the first parameter is COM1 and the
second parameter is 0, which must be placed in the DX register to identify
the port, COM1.
In this case the following values apply: 1200 baud, no parity, 1 stop bit
and 8 data bits. Thus the value in AL must be 100 00 0 11 or 1000 0011 or
$83
program TestAux;
uses AuxInOut;
var
Com1 : text;
begin
AssignAux(Com1,0,$83);
Rewrite(Com1);
Writeln(Com1,'Good morning. Any messages?');
Close(Com1);
end.
where the procedure AssignAux(var F:Text;Port,Params:word); indicates that
Text file = COM1, Port:=0 and Params:=$83 as evaluated above.
The unit AuxInOut is not mentioned in the manuals for version 6.0, but
Borland now provide the Async coms routines on a Pascal Utilities diskette.
The unit ASYNC4U has a function Async_Open, which has the following
parameters: (ComPort : Integer;
BaudRate : Integer;
Parity : Char;
WordSize : Integer;
StopBits : Integer;)
BLAISE Turbo Asynch Plus.
═════════════════════════
Blaise Computing Inc., 2560 Ninth Street, Suite 316, Berkeley, CA 94710
produce Blaise Computing Power Tools Plus, which include Norton Guides,
and also Blaise Turbo Asynch Plus, which provides a set of communication
utilities.
When communicating by means of the serial data ports, the data and the
control information are transmitted over a single line, one bit at a time.
With asynchronous communication, start and stop bits synchronise the
transmission. This compares with synchronous transmission of data which is
according to a definite time schedule.
The Blaise utilities allow: Open COM port, Close, Write, Read COM port,
Set and Return COM port options ( baud, parity, etc ).
The standard IBM COM port addresses are as follows:
Port Base address.
---- -------------
COM1 $03F8
COM2 $02F8
These addresses can be verified by use of the DOS command DEVICE (with some
versions of DOS).
COMPORT.TXT
31.1.90
10.10.92