12.6 Serial Data Communication using BIOS calls

The PC supports up to four Communications Adapters, COM1-COM4, identified by DX=0, 1, 2, or 3 respectively. BIOS interrupt 14h calls with DX=0, 1, 2, or 3 and AH=0, 1, 2, or 3 may be used to initialize the adapter to the character format and the baud rate given in AL, to transmit the character in AL, to put the received character into AL, or to read the modem status into AL. In all cases, the port status is returned in AH. BIOS interrupt 14h calls with AH=4 or 5 provide extended initialization and modem port control.

BIOS call 14h with AH=0 is used to select standard character formats and baud rates by setting AL to BBBPPSLL, where:

In addition, all interrupts from the Adapter are disabled, the port status is returned in AH and the modem status in AL, according to Table 12-3 and Table 12-4 below.

BIOS call 14h with AH=1 waits for Transmit Holding Register Empty (THRE) and transmits the character in AL; it returns with the port status (Table 12-3) in AH, with bit 7 set if a timeout occurred.

BIOS call 14h with AH=2 waits for Received Data Available (RDA) and returns with the received character in AL and the port status (Table 12-3) in AH, with bit 7 set if a timeout occurred.

BIOS call 14h with AH=3 returns the port status (Table 12-3) in AH and the modem status (Table 12-4) in AL.

BIOS call 14h with AH=4 can be used as an alternative to AH=0 to select higher baud rates or more specific serial port parity. Various settings are in BH, BL, CH, and CL.

Note that the BIOS calls with AH=1 or 2 are not fast enough for sustained operation at 1200 baud or more. Note also that BIOS calls cannot be used to control or sense the modem control/device handshaking signals, or to use interrupts.

Table 12-3. BIOS Serial Port Status, Returned in AH

Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
TIMEOUT; function failed Transmit Shift Reg. Empty (TSRE) Transmit Holding Reg. Empty (THRE) Break Detected Framing Error Parity Error Overrun Error Received Data Available (RDA)

Table 12-4. BIOS Modem Port Status, Returned in AL

Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Received Line Signal Detect (RLSD) Ring Indicator (RI) Data Set Ready (DSR) Clear to Send (CTS) Change in RLSD Trailing Edge RI Change in DSR Change in CTS