There are two signals on a serial port which join directly with each other,
forming the most simple electronic circuit (with one line in and one line
out). These signals connect to each other as follows:

RTS (out) - CTS (in)
DTR (out) - DSR (in)

("in" indicates the signal goes into the computer from the external device,
while "out" indicates the signal goes out from the computer to the external
device.)

On a 9-pin serial port, these signals correspond to the following pin
numbers:

RTS: 7
CTS: 8
DTR: 4
DSR: 6

On a 25-pin serial port, these signals correspond to the following pin
numbers:

RTS: 4
CTS: 5
DTR: 20
DSR: 6

When programming serial ports, turning RTS or DTR on or off does *not* change
the voltage level on the pins; Instead, it simply reverses the polarity. With
the signal off, one pin is positive and the other is negative. When the
signal goes on, the polarity is reversed, but the voltage stays the same.

The MCR (Modem Control Register) is used to control the states of RTS and
DTR. The MCR for COM1 is on hardware port 3FCh. The MCR for COM2 is on
hardware port 2FCh.

Here are programs in assembler to turn RTS and DTR on and off. (These are for
COM1. To change them for use with COM2, change all occurrences of "3FC" to
"2FC".)

Turn RTS on:

MOV AL, 2
MOV DX, 3FCh
OUT DX, AL
MOV AX,4C00h ;terminate program
INT 21h

Turn RTS off:

MOV AL, 0
MOV DX, 3FCh
OUT DX, AL
MOV AX,4C00h ;terminate program
INT 21h

Toggle RTS (on or off, whichever it isn't now):

MOV DX, 3FCh
IN AL, DX
XOR AL, 2
OUT DX, AL
MOV AX,4C00h ;terminate program
INT 21h

Turn DTR on:

MOV AL, 1
MOV DX, 3FCh
OUT DX, AL
MOV AX,4C00h ;terminate program
INT 21h

Turn DTR off:

MOV AL, 0
MOV DX, 3FCh
OUT DX, AL
MOV AX,4C00h ;terminate program
INT 21h

Toggle DTR (on or off, whichever it isn't now):

MOV DX, 3FCh
IN AL, DX
XOR AL, 1
OUT DX, AL
MOV AX,4C00h ;terminate program
INT 21h

Using this information, you could hook up an electronic relay between your
serial port and an appliance, allowing you to turn the appliance on or off
from your computer.

    Source: geocities.com/siliconvalley/2072

               ( geocities.com/siliconvalley)