                                      PORT TEST
                     Comprehensive I/O Port Diagnostics for PCs
                                    USER'S MANUAL
                                     Version 1.1

                              MICROSYSTEMS DEVELOPMENT
                               4100 Moorpark Ave. #104
                              San Jose, CA  95117   USA
                                Phone:  (408)296-4000
                                 FAX:  (408)296-5877

                    Copyright (C) MicroSystems Development   1990
                                 All rights reserved

                                  TABLE OF CONTENTS

          1.0  BACKGROUND INFORMATION................................1
               1.1  Serial Port Basics...............................1
               1.2  Parallel Port Basics.............................1

          2.0  ADDRESSING SCHEMES....................................3
               2.1  Port Addressing..................................3
               2.2  What the BIOS does...............................3
               2.3  What DOS does....................................4
               2.4  Logical vs. Physical Addresses...................4
               2.5  Interrupt Usage..................................5

          3.0  SERIAL AND PARALLEL TESTS.............................6

          4.0  COMMAND LINE PARAMETERS...............................7

          In addition to tests and diagnostics, PORT TEST can do
          the following:
	  
               porttest swap lpt1 lpt2
               Swaps table addresses for lpt1 and lpt2.

               porttest com3:19200,n,8,1
               Set baud rate, parity, data bits, and stop bits for a serial
               port.

               porttest as 280
               Adds address 0280 hex to the serial port table as the next
               logical com port.

               porttest ds
               Automatically detects serial ports and updates the table.

          And more...

          1.0  INTRODUCTION

               When computer information, known as data, is sent from one
          device to another, it is carried by a wire cable.  Data is
          generally sent in one of two basic ways.  Many bits at a time
          over many wires in the cable is known as parallel transfer.
          Sending one bit at a time over one wire is known as serial
          transfer.  Each type of transfer has its own advantages and
          disadvantages.  The serial or parallel connections to the
          computer are called PORTS.  Collectively, they are called
          Input/Output, or I/O ports.

               PORT TEST is comprehensive diagnostic program for I/O ports
          installed in IBM PC and AT compatibles computers running DOS.  It
          is useful to identify ports, manipulate system tables, test the
          ports, and to identify and correct problems.  This manual is
          intended to supplement the information provided in PORT TEST by
          explaining the ways in which I/O ports are commonly used and
          implemented in IBM compatible PCs.  It also describes what each
          test does and provides information on what to look for if any of
          the tests fail.

          1.1  SERIAL PORT BASICS

               The PC serial port uses voltages and connectors established
          by the Electronic Industries Association (EIA) standard
          specification known as RS-232C.  In addition to one bit of data,
          other control signals are also sent and received.  Sending data
          one bit at a time is relatively slow, but serial ports have the
          advantage of using fewer wires to connect two devices and being
          able to communicate over relatively long cable distances.  Most
          serial ports can easily communicate over 100 ft of cable.  Data
          is sent using +12 volts and -12 volts to represent a 0 or a 1
          data bit.  In addition, there are a wide variety of serial
          peripherals available which make use of the standard RS-232C
          specification.  Furthermore, recent advances have made serial
          data transmission reliable at higher data rates.  These data
          rates are referred to as "baud" rates.

               The heart of all serial ports is an Asychronous
          Communications Element, referred to as an ACE.  The CPU reads and
          writes a byte (8 bits) of data to this chip, and the ACE handles
          the serial transmissions and other functions related to the RS-
          232C specification.  The ACE used in most PC & XT type (8088 and
          8086) systems is the INS8250B or equivalent.  Most AT class
          machines (80286 & above) use the NS16450 device.  The 16450 chip
          is designed to handle the higher data bus rates of the faster
          computers.  The serial data communications however is identical
          to the 8250.  It is beyond the scope of this manual to describe
          the detailed workings of these chips.  Refer to the
          manufacturer's data sheets for more detailed information.

          1.2  PARALLEL PORT BASICS

               Eight bits of data are transferred at a time over PC
          parallel ports.  Data is sent using +5 volts and 0 volts to
          represent a 1 or a 0 data bit.  As you might expect, data can be
          transferred relatively fast in this manner.  The disadvantages of
          this method is that more wires are needed and that most common
          parallel ports can only work reliably at distances of under 20
          feet.

               Unlike serial ports which rely on a chip to do the data
          transmission, parallel data is handled entirely with software.
          Parallel ports have three registers, one for data out, one for
          output control lines, and one for input control lines.

               The way is which data is transmitted over parallel ports
          varies, but a general description follows.  To send a byte of
          data, the software outputs the byte to the data lines, then
          pulses the STROBE output.  The device on the other end (normally
          a printer) then asserts its BUSY line.  The PC waits for BUSY to
          go away before sending the next byte.  In other implementations,
          the ACKNOWLEDGE line is used for the printer to signal to the PC
          that it has received the data.

               The other control lines are used for various purposes.  On
          the printer side, PAPER-END is a signal to the PC that the
          printer is out of paper.  The printer also sends a SELECTED
          signal to the PC indicating that it is 'on line' and ready to
          receive data.  The ERROR signal from the printer can be used for
          any type of error that would cause the printer to be unable to
          receive data.  In general, if any of these signals are asserted,
          BUSY is also asserted.

               The PC has three additional output control lines.  Usage of
          these lines varies with the particular software and printer in
          use.  In the original PC implementation, they are used as
          follows:  AUTOFEED tells the printer to automatically insert a
          line feed after each carriage return.  INIT initializes the
          printer upon power up.  SELECT deselects the printer and takes it
          'off line'.  SELECT was most often used as a method to signal the
          operator that some attention was required.  For example, when the
          software needed to change to a different font, it would deselect
          the printer.  This would cause the printer to turn off its
          SELECTED line and its front panel light.  The user would then
          change the print wheel in the printer and press the SELECT button
          on the printer.  The printer would then turn on its SELECTED line
          signalling the software to proceed.  Many printers will stay in
          the 'off line' condition for as long as SELECT or INIT are
          asserted even if the SELECT button is pressed.

               As stated earlier, not all of these controls lines are used
          in the same manner.  Some of the latest laser printers on the
          market ignore all the control lines to it except for the STROBE
          line.

          2.0  ADDRESSING SCHEMES

          2.1 PORT ADDRESSING

               Any I/O device in a PC must be located at a particular
          address.  Actually, a serial port consists of eight addresses and
          a parallel port has three.  The address used to refer to a
          particular port is the first or BASE address.  For both serial
          and parallel ports, this first address is where the data to be
          transferred is read and written.

               These addresses are the PHYSICAL addresses of the ports.  It
          is where the Central Processing Unit (CPU) of the PC must read or
          write data to send or receive data over a port.  There are no set
          rules for what addresses must be used for ports, but some
          commonly used addresses are supported by most manufacturers.
          Generally, the first two serial ports are at physical addresses
          3F8 and 2F8.  These are referred to as COM1 and COM2, the LOGICAL
          addresses.   Generally, parallel ports are located at addresses
          3BC, 378 and 278, which are referred to as LPT1, LPT2, and LPT3.
          Many monitor cards have a parallel port built in.  In these
          cases, the port is usually at 3BC.

          NOTE:  The physical addresses are shown in hexadecimal notation.


          2.2  WHAT THE BIOS DOES

               Most PC BIOS routines do a quick check upon power up to
          determine how many serial and parallel ports are installed in a
          system.  They examine specific addresses by writing to them, then
          reading them back to determine if a device is present at that
          address.  The BIOS then places the address of each responding
          device in a table in RAM located at 40:0 for serial ports and at
          40:8 for parallel ports.

               There are eight bytes at each of the above locations
          reserved for port addresses.  Since a port address is two bytes,
          up to four serial and four parallel addresses can be put in the
          tables.

               For example, for a system with two serial ports and two
          parallel ports, typical tables might be:

               Serial Port table:       Parallel port table:
               ADDRESS    DATA          ADDRESS    DATA
                40:0      F8 03          40:8      BC 03
                40:2      F8 02          40:A      78 03
                40:4      00 00          40:C      00 00
                40:6      00 00          40:E      00 00

          Note:  The high & low bytes of the address are reversed in the
          tables.

          2.3  WHAT DOS DOES

               After a PC has booted and the BIOS is no longer in control,
          DOS uses the addresses in these tables as COM1, COM2, etc. for
          serial ports, and LPT1, LPT2, etc. for parallel ports.  For
          example, DOS includes a program called MODE to set various
          parameters such as the baud rate, of a port.  In order to use the
          MODE command, the user must refer to the desired port by its COM
          or LPT assignment.  The physical address used is the one stored
          in the table.  It is very possible that COM1 in one system is not
          at the same physical address as COM1 in another system.

               In order for DOS to recognize a COM or LPT number, there
          must be a valid address listed in the table, and there can be no
          gaps.  If there is a zero entry in the table, DOS considers that
          the end of the list.  Therefore, as far as DOS is concerned, it
          is impossible to have a COM1 & a COM4 without having a COM2 &
          COM3 also!  Other software may report differently as explained
          below.

          2.4  LOGICAL VS. PHYSICAL ADDRESSES

               Many BIOS routines only check for two serial ports and three
          parallel ports.  As PCs became more popular, the need for more
          ports grew.  This fact was 'fixed' by DOS Versions 3.3 and
          higher, which will recognize up to four COM and four LPT ports.
          However, DOS will only recognize a logical port whose physical
          address has been placed in the RAM table.  If the BIOS doesn't
          put the physical address there upon power up, DOS won't recognize
          a logical port even when the hardware is properly configured and
          installed!

               If you need to use DOS to support more ports than your BIOS
          will detect and install, PORT TEST can be used to place the
          correct address in the system tables.  You can use the
          interactive mode, but PORT TEST's batch mode was specifically
          designed for this purpose.

               Place the command:  porttest /ds /dp  in your autoexec.bat
          file to automatically detect serial and detect parallel ports in
          your system upon power up.  These ports will now be recognized by
          DOS.  See "Command Line Parameters" for more information.

          NOTE:      Many application programs do not use DOS to interface
          to ports, so that it may not be necessary to include a port's
          address in the system tables.  However, you must place the
          address in the table in order to test a port with PORT TEST.

               Considerable confusion exists regarding proper logical and
          physical port address.  Strictly speaking, there is no proper
          physical address for any of the logical ports.  The logical port
          structure permits any physical address to be placed into its
          tables.

               Many application programs access ports directly, and do not
          use the built in routines in the hardware's BIOS.  This is
          usually done because the application needs a more sophisticated
          device driver than is provided by the BIOS.  When this is the
          case, the logical port addresses are not always used properly.
          Some applications access ports directly, but properly determine
          the physical address from the logical address by using the table
          at 40:0.  Other programs do not use logical addresses at all, and
          just refer to physical addresses.  Still others convert logical
          to physical addresses using their own table.  In this case, the
          program could report that there is a COM1 and a COM4 installed
          with no COM2 or COM3!

          2.5  INTERRUPT USAGE

               In addition to a serial port's registers, the ACE also has
          the ability to interrupt the processor, either after it has
          transmitted a byte of data, or after it has received one.
          Ideally, the interrupt request line that each port uses should be
          unique, but there are not always enough interrupts to go around.
          Therefore, interrupts are sometimes used by more than one device.
          This is ok as long as only one of the devices is active at a
          time.

               A standard PC has eight hardware interrupt request lines.
          Often, IRQ4 is used for the serial port at address 3F8 and IRQ3
          is used for the port at address 2F8.  This is what PORT TEST
          assumes unless told otherwise.  For other serial ports, the user
          must assign the proper IRQ number (if any) in PORT TEST.  If left
          unassigned, PORT TEST will skip the interrupt tests.

               Most I/O cards have jumpers to select which interrupt will
          be used.  If there are conflicts, the user should examine these
          jumpers to determine the cause of conflict.

               Some parallel ports can be configured to use IRQ7.  When
          enabled, the processor will receive an interrupt when
          /ACKNOWLEDGE (pin 10) transitions from high to low.  This is not
          supported on all cards and few applications use this feature.
          PORT TEST does not test parallel port interrupts.

          3.0  SERIAL AND PARALLEL TESTS

               Detailed information on the content of the tests is in the
          manual which comes with the registered version of PORT TEST.

          4.0  COMMAND LINE PARAMETERS

               In addition to its interactive mode, PORT TEST supports
          several command line parameters as follows:

          Usage:    porttest [mode switches] [batch commands]

               All command line parameters are optional.

               mode switches:
                    /p  = Use the system's default print screen handler
               Normally PORT TEST uses its own print screen handler so that
               linedraw and other non printable characters are replaced
               before printing.  If your printer has the capability to
               print these characters, then use this command line option to
               turn off PORT TEST's character translation when doing a
               Print Screen.

                    /m  = force Monochrome on color monitors
                    
                    /i  force interactive mode
                         (default when no batch args)

               batch commands:

               detectserial        OR ds        ->  detect serial ports
               detectparallel      OR dp        ->  detect parallel ports
               addserial <hex>     OR as <hex>  ->  add serial port
               addparallel <hex>   OR ap <hex>  ->  add parallel port
               com#:<b>,<p>,<d>,<s>             ->  set serial parameters
               addserial <hex>:<b>,<p>,<d>,<s>  ->  add and set parameters
               delete com# OR delete lpt#       ->  delete port
               swap com# com# OR swap lpt# lpt# ->  swap ports

               Examples of command line usage:

               porttest ds
               Automatically detects serial ports and updates the table.

               porttest as 280
               Adds address 0280 hex to the serial port table as the next
               logical com port.

               porttest com3:9600,n,8,1
               Set baud rate, parity, data bits, and stop bits for a serial
               port.

               porttest swap lpt1 lpt2
               Swaps table addresses for lpt1 and lpt2.
