Filename: SWAPLPT.TXT WWW URL: http://www.firmware.com/support/bios/swaplpt.htm FTP URL: ftp://ftp.firmware.com/text/swaplpt.txt Revision: 11/06/96 TLS Micro Firmware Technical Suport Keywords: LPT, printer port, DEBUG Summary: DEBUG session to create a program to reverse LPT1 and LPT2 assignments.
This file was created in response to a customer who had a need to swap LPT ports so that the output of PRINTSCREEN would go to his printer attached to LPT2. PRINTSCREEN is a BIOS function and will always send its output to LPT1. Note that all addresses are in hexadecimal format.
The addresses 3BC, 378, and 278 are used for LPT ports. The BIOS will assign the first port it finds in the above order as LPT1, the next as LPT2, etc. So if only one LPT port exists and it is at 278, that will be LPT1. If there is a 3BC and a 378, 3BC will be LPT1 and 378 will be LPT2.
First use DEBUG to determine what addresses are being used by the first two LPT ports.
C:\>DEBUG - D 40:8 L4 xxxx:xxxx BC 03 78 03 (output from DEBUG) -Q (quits to DOS prompt)In the above example, there are 2 LPT ports, at 3BC and 378. Note that the addresses are listed with the hex pairs of each address reversed. The first address listed is LPT1, the second is LPT2. This step is not really necessary except to verify that there are actually 2 LPT port addresses being detected. Do not run SWAPLPT.COM if there is only one LPT port listed in the above DEBUG output.
The following DEBUG session will create a COM file named SWAPLPT.COM which will reverse the two LPT ports so that the first one will change from LPT1 to LPT2 and the second one will change from LPT2 to LPT1. Running the program a second time will reverse them back to their original order. Also just rebooting the system will cause the ports to revert to their original order. Note that the reassignment of the ports will take effect in any software programs that use BIOS calls for printing.
C:\>DEBUG - A 100 xxxx:xxxx POP ES (ignore xxxx:xxxx segment:offset values) xxxx:xxxx PUSH ES xxxx:xxxx ES: xxxx:xxxx MOV AX,[408] xxxx:xxxx ES: xxxx:xxxx XCHG [40A],AX xxxx:xxxx ES: xxxx:xxxx MOV [408],AX xxxx:xxxx INT 20 xxxx:xxxx (Press ENTER an extra time here to return to dash prompt) - RCX CX 0000 (output from DEBUG) :18 - N SWAPLPT.COM (names the file) - W (writes file to disk) Writing 00018 bytes (output from DEBUG) - Q (quits to DOS prompt)Also the same thing can be accomplished "manually" with DEBUG with the following command, where nn nn is the reversed address of LPT2 and xx xx is the reversed address of LPT1.
C:\>DEBUG - E 40:8 nn nn xx xx - QThe DEBUG example given at the beginning of this file to detect the LPT port addresses can be used to verify that SWAPLPT.COM did actually reverse the ports.