Contents of the MODESW.DOC file
Written by: Mark Ehr
Copyright (C) 1985 Technical Support Services
1200 South Wadsworth Blvd.
Lakewood, CO 80226
The IBM PC Software Experts.
This program is hereby placed in the public domain. It may be
reproduced and modified freely, provided that the opening notice
remains intact and that no fee is charged.
MODESW allows the user to redirect his printer or
communications ports. It can be viewed as an extension to IBM's
MODE command, which allows you to redirect the LPT port to the COM
port. This program came into being as a result of the need of a
client of mine to send all data originally intended for LPT1 to
LPT2. As MODE does not support this feature, I decided to create
it. In the process I added the ability to redirect the COM ports
To use MODESW, simply invoke it from DOS in the following
Where [switch] is one of the following:
-b = switch both LPT and COM ports.
-c = switch only the COM ports.
-p = switch only the LPT ports.
-s = display the current status of redirection.
If you enter MODESW with no options specified, it will display a
help screen that summarizes the switches.
MODESW Technical Description
For those of us that are technically oriented, here is a
description of how MODESW works. Those of you that aren't
interested in this aspect, enjoy the program!
Basically, MODESW works by swapping addresses of the COM and
LPT ports that exist in the ROM BIOS Data Area, which begins at
0040 hex. These areas can be examined in the IBM Technical
Reference, beginning on page A-1. MODESW takes the values for
RS232_BASE and PRINTER_BASE and swaps them. A diagram of this
Address Description Normal Contents
------- ----------------------------- ---------------
0040h RS232_BASE Address for COM1 03F8h
0042h RS232_BASE Address for COM2 03F9h
0048h PRINTER_BASE Address for LPT1 0378h/03BCh *
004Ah PRINTER_BASE Address for LPT2 0379h
* - This value is different if an IBM Monochrome display adapter
is in the system instead of a standard IBM Parallel adapter. The
monochrome adapter's address is 03BCh to prevent interference with
other parallel boards in the system.
As a result, when MODESW switches COM1 and COM2 values and
an applications program sends data to the COM1 data area, it
automatically goes out COM2 (03F9h)! The same is true for LPT1
and LPT2. Note that if no port exists, (i.e., no COM2) the
location will contain zeros (0000). The program still works,
except that data gets sent to the celestial bit bucket at 0000. As
you can see, a fairly simple solution for a potentially difficult
In conclusion, I would like to thank Thomas Ahlstrom of
United Airlines for his assistance in the detective work that was
necessary to develop this program.
13 November, 1985