Port address
In general, the I / O address of the COM port is fixed.
3F8 / 2F8 BaseAdd 0 Transmit / Receive Buffer
3F9 / 2F9 BaseAdd 1 Ier
3FA / 2FA BaseAdd 2 IIR (READ) / FCR (WRITE)
3FB / 2FB BaseAdd 3 LCR
3FC / 2FC BaseAdd 4 MCR
3FD / 2FD BaseAdd 5 LSR
3FE / 2FE BaseAdd 6 MSR
3FF / 2FF BaseAdd 7 Scratch Pad Register
Abbreviate
CD - Carrier Detect
CTS - CLEAR TO Send
DCD - Data Carrier Detect
DCE - DATA Communication Equipment
DDCD - Delta Data Carrier Detect
DLAB - BAUD RATE DIVisor
DSR - Data Set Ready
DTE - DATA TERMINAL EQUIPMENT
DTR - DATA TERMINAL READY
FCR - FIFO Control Register
FIFO - FIRST IN FIRST OUT
Ier - Interrupt Enable Register
IIR - Interrupt Identification Register
LCR - LINE Control Register
LSR - LINE STATUS Register
MCR - MODEM Control Register
MSR - MODEM STATUS Register
RD - Receive Data
Ri - Ring Indicator
RTS - Request to Send
TD - Transmit Data
THRE - Transmitter Holding Register EMPTY
TSRE - Transmitter Shift Register Empty
Set Baud Rate
When LCR (Base Address 3) bit7 is 1, the data written to Base 0 / Base 1 is the baud rate to be set.
Baud RateBase 1Base 0Baud RateBase 1Base 0500x090x0024000x000x301100x040x1736000x000x201500x030x0048000x000x183000x010x8072000x000x106000x000xC096000x000x0C12000x000x60192000x000x0618000x000x40384000x000x0320000x000x3A576000x000x021152000x000x01
Example Code: BAUDRATABLE: DW 01H; 115200 0 DW 02H; 57600 1 DW 03H; 38400 2 DW 06H; 19200 3 DW 0CH; 9600 4 MOV DX, Base 3 in Al, DX JMP Short $ 2; Delay OR Al, 80h OUT DX, Al; SET LCR BIT7 JMP SHORT $ 2 Push Ax; Save The Data Lea Si, CS: BaudrateTable SHL BX, 1; BX = 0/1/2/3/4 Add Si, Bx; Si Point THE Divisor Mov AX, Word PTR CS: [Si]; Al, Base 0 Value; AH, Base 1 Value Mov DX, Base 0 Out DX, Al Jmp Short $ 2 Xchg Ah, Al Inc DX Out DX, Al JMP SHORT $ 2 POP AX and Al, 07FH; Clear Bit7 MOV DX, Base 3 Out DX, Al Jmp Short $ 2Transmission Parameters Knowledgelcr Bit1 Bit0 ---- Word LENGTH 0 0 0 5 Bit 0 1 6 Bit 1 0 7 Bit 1 1 8 Bit
LCR bit2 ---- Stop Bits LENGTH 0 1BITS 2 2BITS LCR BIT3 ---- Parity or Not 0 Disable Parity 1 Enable Parity LCR bit5 bit4 ---- Parity Control 0 0 ODD PARITY 0 1 Even Parity 1 0 parity is always 1 1 1 Parity Is Always 0 If we want to set the word length 8, the stop bit is 1, the no parity verification procedure is as follows:
Sample Code MoV DX, Base 3 in Al, DX JMP Short $ 2 OR Al, 03; SET 8bit and Al, 011111011B; Set 1 Stop Bit And Al, 011110111b; Set No Parity Out DX, Al JMP Short $ 2