Ref: 99980062
Title: Application Note-EtherTerm Bios Interrupt 14H Emulation
Date: 4/1/86

Copyright 3Com Corporation, 1991.  All rights reserved.

This application note describes how to design and develop
application programs that use the EtherTerm BIOS Interrupt 14H
Emulation.  This feature provides a programmatic byte stream
interface to EtherTerm.  Applications such as terminal emulators
and file-transfer utilities can use this interface to send and
receive data through a connection initiated by EtherTerm.

BIOS Interrupts

The basic input/output system (BIOS) resides in ROM on the IBM PC
System board.  BIOS routines allow the programmer to perform
block or character Input/Ouput operations without knowing the
device address.

Access to BIOS is through the Intel 8088 software interrupts.
There are 11 interrupts (from 10 hex through 1A) accessible via
BIOS routines.

To call a BIOS Interrupt, the following instruction should be
inserted in the routine:

            INT <number ranging form 10 to 1A>H

Calls to BIOS Interrupt 14H normally allow communications through
a serial card installed in the PC.  EtherTerm BIOS Interrupt 14H
Emulation redirects the Input/Output request to EtherTerm for
transmission or reception to/from the network.  Since most off-
the-shelf programs access the hardware communications port
directly, bypassing Interrupt 14H, they will require modification
to use the EtherTerm BIOS Interrupt 14H Emulation.

.h1;Function of BIOS Interrupt 14H

The following list describes functions provided by  BIOS
Interrupt 14H.  For each function, the DX register contains a
communication port number.  If the DX register is set to 0, Input/
Output will be redirected to communication port number 1.  If the
DX register is set to 1, Input/Output will be redirected to
communication port number 2.

Function 0 is used to initialize the parameters of the
communicaitons (RS-232) port.  To initialize the communication
port parameters, register AH is set to 0.  Register AL contains
parameters for initialization.  On return, conditions are set as
in a call for the communication status in function 3.

Function 1 is used to send a character to the communication port.
To do this, register AH is set to 1.  The character in register
AL is then sent over the communications lines.  In function 1,
register AL is preserved.

Function 2 is used to receive a character from the communication
port.  Register AH is set to 2.  The received character is placed
in register AL before returning to the caller.

Function 3 is used to request the status of the RS-232 port.  The
status of the RS-232 port is returned to the caller in register
AX.

For more detailed descriptions of the ROM BIOS Interrupt 14H
functions, refer to the IBM Technical Reference Manual.

.h1;EtherTerm BIOS Interrupt 14H Emulation

In order to use the Interrupt 14H Emulation, the user's program
must meet the following conditions:

1.  The user's application program must be relocatable; this is
normally indicated by a filename with an .EXE as a suffix.
If the program is located in the same directory as EtherTerm,
only the filename needs to be specified when running the
application from EtherTerm.  If it is located in another
directory, a full pathname should be used.

2.  BIOS Interrupt 14H function 0 is normally used to initialize
the parameters of the communication port.  However, it has no
effect on EtherTerm.  Function 0 returns a value of 60b0H in
register AX.  Register AX is a 16-bit register in which
register AH is a most significant byte and register AL is a
least significant byte.  Note that this function performs no
action with EtherTerm and need not be used with EtherTerm
Interrupt 14H Emulation.

The following list describes the representation of each bit
in register AX as well as the setting of these bits to create
a value of 60b0H:

    AH      bit 7: timeout                          ... 0
            bit 6: transmit shift register empty    ... 1
            bit 5: transmit holding register empty  ... 1
            bit 4: break detect                     ... 0
            bit 3: framing error                    ... 0
            bit 2: parity error                     ... 0
            bit 1: overrun error                    ... 0
            bit 0: data ready                       ... 0

   AL       bit 7: received line signal detect      ... 1
            bit 6: ring indicator                   ... 0
            bit 5: data set ready                   ... 1
            bit 4: clear to send                    ... 1
            bit 3: delta receive line signal detect ... 0
            bit 2: trailing edge ring detector      ... 0
            bit 1: delta data set ready             ... 0
            bit 0: delta clear to send              ... 0

3.  In order to be trapped and transmitted by EtherTerm,
characters must be written to the communication port using
BIOS Interrupt 14H function 1.

If the character has been accepted by EtherTerm, register AH
will contain 60H (60 in hexadecimal).  The following list
describes the representation of each bit in register AH as
well as the setting of these bits to comply with the value of
register AH when a character is accepted by EtherTerm:

        AH      bit 7: timeout                          ... 0
                bit 6: transmit shift register empty    ... 1
                bit 5: transmit holding register empty  ... 1
                bit 4: break detect                     ... 0
                bit 3: framing error                    ... 0
                bit 2: parity error                     ... 0
                bit 1: overrun error                    ... 0
                bit 0: data ready                       ... 0

If EtherTerm could not accept the character, register AH will
contain 80H (80 hexadecimal) as follows:

        AH      bit 7: timeout                          ... 1
                bit 6: transmit shift register empty    ... 0
                bit 5: transmit holding register empty  ... 0
                bit 4: break detect                     ... 0
                bit 3: framing error                    ... 0
                bit 2: parity error                     ... 0
                bit 1: overrun error                    ... 0
                bit 0: data ready                       ... 0

For more detailed descriptions of the bits in register
AH, refer to the IBM Technical Reference Manual.

4.  Characters must be read from the communication port using
BIOS Interrupt 14 function 2.  Ethernet has a character
ready, it returns the character in register AL.  Register AH
contains a value of 60H.  If no character is ready, register
AL contains a value of 00H and register AH contains a value
of 80H (refer to the list in item 3 for an example).  In this
case, the register AL does not contain a character;
therefore, the bits in the register have no meaning.

The following list describes the representation of each bit
in register AL as well as the content of these bits if
EtherTerm does not have a character ready:

    AH  bit 7: timeout                          ... 0
        bit 6: transmit shift register empty    ... 1
        bit 5: transmit holding register empty  ... 1
        bit 4: break detect                     ... 0
        bit 3: framing error                    ... 0
        bit 2: parity error                     ... 0
        bit 1: overrun error                    ... 0
        bit 0: data ready                       ... 0

For more detailed descriptions of the bits in register AL,
refer to the IBM Technical Reference Manual.

5.  BIOS Interrupt 14 function 3 is used to ready the status of
the communications port.  If general, it is better to use
only functions 1 and 2 and to determine status on the return
from these functions.  Function 3 is redundant and slows down
the emulation process.  This function is useful when there
is no character to read or write but control is to be given
to EtherTerm.  If no data is available, a value of 60b0H is
returned to register AX, which is the status returned by
function 0 as described in item 2 above.  If data is
available, register AX will contain a value of 61b0H as
follows:

    AH      bit 7: timeout                         ... 0
            bit 6: transmit shift register empty   ... 1
            bit 5: transmit holding register empty ... 1
            bit 4: break detect                    ... 0
            bit 3: framing error                   ... 0
            bit 2: parity error                    ... 0
            bit 1: overrun error                   ... 0
            bit 0: data ready                      ... 1

    AL      bit 7: received line signal detect     ... 1
            bit 6: ring indicator                  ... 0
            bit 5: data set ready                  ... 1
            bit 4: clear to send                   ... 1
            bit 3: delta receive line signal detect... 0
            bit 2: trailing edge ring detector     ... 0
            bit 1: delta data set ready            ... 0
            bit 0: delta clear to send             ... 0

If there is no room to receive a character, bit 5 of register
AH is reset to 0 indicate that the transmit holding register
is full.

6.  BIOS Interrupt 14 function 4 is used to send a break signal
to the host.  Function 4 is not a ROM BIOS Interrupt 14H
function; it is only used in BIOS Interrupt 14H Emulation.
This function requires no parameters and returns no
parameters.

7.  In order for the EtherTerm to maintain its end of the
connection with a host, it must send Sequence Packet Protocol
(SPP) probe packets to the host.  If more than 20 seconds go
by without the host receiving an SPP probe packet, the host
will terminate the connection.  Note that the SPP probe
packet is retransmitted five times if it is not received.
The five retries are sent within a 20-second interval.

To ensure that SPP probes can be transmitted, the user
emulator should not go more than 10 seconds without giving
EtherTerm control by issuing a BIOS Interrupt 14 function
1, 2, 3, or 4.

8.  The user program may not be able to communicate with the
Network management port (!136) of the Bridge Communications
Server.  Users should normally use the EtherTerm emulator to
connect to this port, although because of the local echo
involved, they may try to use an alternative emulator.

.h1;Sample Routines in Calling Interrupt 14

The following examples illustrate the use 8088 instructions to
call BIOS Interrupt 14 functions 0, 1, 2, 3, and 4.  Note that
register DX contains parameters indicating whether communication
port 0 or 1 is to be used.  Similar to register AX, register DX
is a 16-bit register in which register DH is a most significant
byte and register DL is a least significant byte.

EtherTerm assumes that the first RS-232 port number that the
Interrupt 14H encounters is the one for which the redirection is
taking place.  Interrupt 14H calls for the other RS-232 port will
be passed through to ROM BIOS Interrupt 14H.

;Main Program Loop
 main:
;check if data available from EtherTerm

    mov  ah, 2   ;perform function 2
    xor  dx, dx  ;set the contents of DX:DX=0-port,DX=1-port2
    int  14h     ;call Interrupt 14H
    test ah, 80h ;is there any character?
    jnz  main2   ;if not, check whether data is available to
                  transmit

;received data from EtherTerm
;data in AL register
   {perform character processing}
;main2:
;check if data available to transmit
   {check for data to send}

    jz   main

;give data to EtherTerm to transmit
;data in AL register

    mov  ah, 1  ;perform function 1
    xor  dx, dx ;set the contents of DX:DX=0-port 1, DX=1-port 2
    int  14h    ;call Interrupt 14H
    jmp  main   ;check for next character

;this example shows the sequence of commands used to transmit a
break
;send a signal to the host

    mov   ah, 4 ;perform function 4
    int   14h   ;call Interrupt 14H

