DEFINT A-Z SUB baudrate (func, port, baud, err.code) STATIC 'INPUT: FUNC=0 - return the current baud rate in BAUD ' FUNC=1 - set the baud rate from BAUD 'See the Serial/Parallel Adapter Tech.Ref. for details err.code = 0 IF (port <> 1 AND port <> 2) THEN err.code = -1: GOTO finito IF func = 1 AND baud < 100 THEN err.code = -2: GOTO finito ADDR = &H4F8 - (&H100 * port) ' base address of port reg's ADDR.LCR = ADDR + 3 ' Line Control Register ADDR.DL.LSB = ADDR + 0: ADDR.DL.MSB = ADDR + 1' Divisor Latch LSB & MSB VAL.LCR = INP(ADDR.LCR) ' get old LCR value OUT ADDR.LCR, VAL.LCR AND &H7F ' Disable DLAB to get to inters VAL.INT = INP(ADDR.DL.MSB) ' Get the int enable statuses OUT ADDR.DL.MSB, 0 ' Disable all modem intertupts OUT ADDR.LCR, VAL.LCR OR &H80 ' Enable DLAB to gain access IF func = 0 THEN GOTO getbaud ' if get then go DIVISOR = (1843200! / baud) / 16'see page 17 of the SERIAL/PARALLEL ADAPTER ( in the back of the PC-AT TECH.REF.) MSB = DIVISOR \ 2 ^ 8: LSB = DIVISOR MOD 2 ^ 8 OUT ADDR.DL.MSB, MSB OUT ADDR.DL.LSB, LSB' put out the new baud rate GOTO finito getbaud: 'get the current baud rate MSB = INP(ADDR.DL.MSB) LSB = INP(ADDR.DL.LSB)'get old baud rate DIVISOR = MSB * 2 ^ 8 + LSB baud = (1843200! / DIVISOR) / 16 finito: IF err.code = 0 THEN OUT ADDR.LCR, VAL.LCR AND &H7F ' Disable DLAB to get to inters OUT ADDR.DL.MSB, VAL.INT ' Replace orig. inter. values OUT ADDR.LCR, VAL.LCR ' Replace orig. LCR values END IF EXIT SUB END SUB