Question

I'm supposed to modify an application written in 16-bit assembly which uses serial port. One of the objectives is to support speed of 19200 baud. Most of the resources I've read (for example this) on the Internet show the way of doing it using INT 14h. I basically write a magic number into al register, call the interrupt and the port is (hopefully) set. The OS's system call application is using to set up the serial port is using the same method (I'm free to modify it if needed).

The problem with that approach is that the field which sets the speed is a 3-bit field and the maximum speed if 9600 baud. How do I use higher speeds?

Was it helpful?

Solution

I'm not too familiar with BIOS functionality, but if you know more about the serial port's underlying UART chip, you can very probably program it directly, bypassing the BIOS' support for it.

For instance, the classic 16550 UART (a datasheet for which is found for instance here) supports up to around 1 Mbps, and uses two 8-bit registers to express the desired clock scaling.

Here is a reference text on doing exactly that, i.e. programming the "divisor latch bytes" to set a desired baud rate. It's clear from the accompanying code that for a COM1 with a base I/O address of 0x3f8, you will find the low-order divisor byte at 0x3f8 and the high-order byte at 0x3f9.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top