Technical information

Aterm Serial Solutions
jnc opnc01 ;Carry clear means no error.
;deal with error
mov ax, fromctrl ;Print out error message
mov bx, offset openfail1
call screen
mov bx, offset comname
call screen
mov bx, offset openfail2
call screen
mov ax,0FFFFH ;Flag bad port
mov comport,ax
jmp short opnc02 ;exit
opnc01:
mov comport,ax ;Save file handle
call uncook ;Set file to raw data mode
opnc02:
ret ;Done
open_com endp
;
The DOS function 3DH, open handle, is used to ’open’ the
com port. It takes two operands, the name of the file and a byte
which defines how the file will be used. If the open fails
(comname may have been set to a non-valid device with the C
command in ATERM) then DOS returns with carry set.
Open_com tests this and generates an error message if the carry
flag is set. If the file is successfully opened DOS returns a word
handle which is stored in the variable comport. The handle is
DOS’ way of identifying the file when ATERM later accesses it.
If the open fails a dummy value of -1 ( 0FFFFH ) is used.
At this stage the device driver has not been accessed. The
open handle function allows DOS to prepare for I/O to the port,
setting up its variables and buffers.
MS-DOS will by default alter certain control characters as
they are sent and received. We can alter the mode that DOS
assigns to the file from the default (called ’cooked’, where
translations are performed) to a more direct one (called ’raw’).
The raw mode has the advantage that data transfers are
performed on as many bytes as possible at a time, rather than
one byte at a time, as cooked mode does. The change from
cooked to raw mode is performed by the subroutine uncook.
Chapter 8 Page 131