
Interfacing the Standard Parallel Port http://www.senet.com.au/~cpeacock
Interfacing the Standard Parallel Port Page 6
The above table, table 3, shows the address at which we can find the Printer Port's addresses in
the BIOS Data Area. Each address will take up 2 bytes. The following sample program in C, shows
how you can read these locations to obtain the addresses of your printer ports.
#include <stdio.h>
#include <dos.h>
void main(void)
{
unsigned int far *ptraddr; /* Pointer to location of Port Addresses */
unsigned int address; /* Address of Port */
int a;
ptraddr=(unsigned int far *)0x00000408;
for (a = 0; a < 3; a++)
{
address = *ptraddr;
if (address == 0)
printf("No port found for LPT%d \n",a+1);
else
printf("Address assigned to LPT%d is %Xh\n",a+1,address);
*ptraddr++;
}
}
Software Registers - Standard Parallel Port (SPP)
Offset Name Read/Write Bit No. Properties
Base + 0 Data Port Write (Note-1) Bit 7 Data 7 (Pin 9)
Bit 6 Data 6 (Pin 8)
Bit 5 Data 5 (Pin 7)
Bit 4 Data 4 (Pin 6)
Bit 3 Data 3 (Pin 5)
Bit 2 Data 2 (Pin 4)
Bit 1 Data 1 (Pin 3)
Bit 0 Data 0 (Pin 2)
Table 4 Data Port
Note 1 : If the Port is bi-directional then Read and Write Operations can be performed on the Data
Register.
The base address, usually called the Data Port or Data Register is simply used for outputting
data on the Parallel Port's data lines (Pins 2-9). This register is normally a write only port. If you read
from the port, you should get the last byte sent. However if your port is bi-directional, you can receive
data on this address. See Bi-directional Ports for more detail.
Commenti su questo manuale