Configure Serial Ports with MS-DOS 6.22 MODE
In MS-DOS 6.22, the MODE command configures serial
communication ports (COM1, COM2, COM3, and COM4) to ensure proper data
transmission between the operating system and serial peripherals such as
modems, serial printers, and terminals. By directly programming the
system's Universal Asynchronous Receiver-Transmitter (UART) controller
and updating the BIOS Data Area, MODE establishes critical
communication parameters, including baud rate, parity, data bits, stop
bits, and timeout handling.
Command Syntax
The MODE utility accepts configuration arguments using
either a detailed keyword syntax or a positional shorthand syntax.
The standard keyword syntax is:
MODE COMm[:] [BAUD=b] [PARITY=p] [DATA=d] [STOP=s] [RETRY=r]
The shorthand positional syntax is:
MODE COMm[:] [b[,p[,d[,s[,r]]]]]
Parameter Details
- Port (
COMm): Specifies the asynchronous communications port number, ranging fromCOM1toCOM4. The colon following the port name is optional. - Baud Rate (
BAUD=b): Defines the transmission speed in bits per second. Supported values include 110, 150, 300, 600, 1200, 2400, 4800, 9600, and 19200. MS-DOS 6.22 allows the value to be abbreviated to the first two digits (e.g.,96for 9600,19for 19200, or12for 1200). - Parity (
PARITY=p): Configures error checking for data integrity. Supported options are:N– NoneE– Even (MS-DOS default)O– OddM– MarkS– Space
- Data Bits (
DATA=d): Specifies the number of information bits per character. Valid options are 5, 6, 7, or 8. The default setting is 7. - Stop Bits (
STOP=s): Designates the end of a transmitted character frame. Valid options are 1, 1.5, or 2. If the baud rate is set to 110, the default is 2; for all other baud rates, the default is 1. - Retry Action (
RETRY=r): Dictates how DOS responds when the port is busy or fails to respond. This setting installs a small Terminate-and-Stay-Resident (TSR) routine to manage port polling:E– Returns an error immediately if the port is busy.B– Returns a "busy" code if the port is busy.P– Continuously retries until the device accepts the data (infinite retry).R– Returns a "ready" signal if the port is busy.N– Performs no retry action (default behavior).
Examples
To configure COM1 for the widely used standard of 9600
baud, no parity, 8 data bits, and 1 stop bit (9600-8-N-1):
MODE COM1:9600,N,8,1
Using the explicit keyword syntax for the same configuration with persistent retry enabled:
MODE COM1 BAUD=9600 PARITY=N DATA=8 STOP=1 RETRY=P
Hardware Execution
When executed, MODE.COM calls BIOS interrupt
INT 14h (Service 00h) to initialize the port parameters and
writes directly to the UART registers (such as the 8250, 16450, or 16550
UART chips) at their respective I/O base addresses (e.g., 03F8h for
COM1, 02F8h for COM2). It sets the divisor latch bytes to achieve the
specified baud rate and sets the Line Control Register (LCR) to match
the selected parity, data bits, and stop bits. Once configured, the port
retains these hardware settings until another software utility
reconfigures the UART or the system is rebooted.