IBM-PC Parallel Printer Port
Finding out how many ports are present and where
Normally, a PC can have up to 3 parallel printer ports - LPT1, LPT2 & LPT3.
Their (16-bit) base addresses in the processor's I/O space are loaded into
memory when the machine is booted, starting at address 408 Hex.
A well-written program requiring direct access to any of these ports
should endeavour to find out which are present and where at run-time (rather
than use constant declarations as in my earlier examples!)
Due to 80x86 processors being
"
little-endian",
the addresses are stored as follows -
408 | 409 | 40a | 40b | 40c | 40d |
LPT1 | LPT2 | LPT3 |
low byte | high byte | low byte | high byte | low byte | high byte |
|
For example, the following values -
408 | 409 | 40a | 40b | 40c | 40d |
78 | 03 | 78 | 02 | 00 | 00 |
|
mean that LPT1 is at 378 Hex, LPT2 is at 278 Hex, and LPT3 is not present.
- Here are some example programs that report which LPT ports are present and
where -
Turbo Pascal
Borland C
MS-QBasic
or you can use
Debug
- An alternative method, which doesn't require direct memory access, would be
to write a test byte to each of the three potential base addresses
(278 / 378 / 3BC Hex) in the processor's I/O space.
Any that can be read back successfully indicate that there must be a port at
that address. But this won't tell you which corresponds to
LPT1, 2 and 3 if more than one parallel port is present.
- You can use the
Microsoft Diagnostics
program to find out the base address of your PC's Parallel Printer Port(s).
- If you are running Windows95, you can view the PC's
Printer Port Properties
[ Previous ]
[ Index ]
last updated: 18-Apr-97
Ian Harries
<ih@doc.ic.ac.uk>