The serial port hardware has several registers to cater to different functionalities. Some of the useful registers are:

Line control register       LCR
     For configuring the serial port. (Address: comport + 3)
Receiver buffer register    RBR
     Holds the data received via the serial port. (comport + 0)
Transmitter Buffer register TBR
     Holds the data to be transmitted.(comport + 0)
Line status register        LSR 
     Holds the info regarding the line status.(comport + 5)

where comport should be replaced with your COM1 or COM2 address.

Following are some basic guidelines for programming the serial port:

  1. To program the serial port you must first initialize the Line Control register of your port with the required baud rate, number of data bit, desired Parity etc. The initialization value is 0x03 for a no parity, 1 stop bit and 8 data bit configuration.
  2. Then you must read the LSR to see if any data is received.
  3. If data is received then you must read the data from the RBR.
  4. For writing data, you must check the LSR to see if the port is ready to send data.
  5. Then you must write the data to the TBR to send data via the port.

This is just a very brief introduction and you need to pick up more to go into serial programming.