The printer adapter responds to five I/O instructions: two output and three input. The output instructions transfer data into two latches whose outputs are presented on the pins of a 25-pin D-type female connector.
Two of the three input instructions allow the processor to read back the contents of the two latches. The third allows the processor to read the realtime status of a group of pins on the connector.
A description of each instruction follows
Output to address 278/378/3BC Hex
Bit 7 6 5 4 3 2 1 0
Pin 9 8 7 6 5 4 3 2
The instruction captures data from the data bus and is present on the respective pins. These pins are each capable of sourcing 2.6 mA and sinking 24 mA. It is essential that the external device not try to pull these lines to ground.
Output to address 27A/37A/3BE Hex
Bit 7 6 5 4 ~3 2 ~1 ~0
Pin - - - IRQ 17 16 14 1
enable
This instruction causes the latch to capture the least significant bits of the data bus. The four least significant bits present their outputs, or inverted versions of their outputs, to the respective pins shown above. If bit 4 is written as 1, the card will interrupt the processor on the condition that pin 10 transitions high to low.
These pins are driven by open collector drivers pulled to +5 Vdc through 4.7 k-ohm resistors. They can each sink approximately 7 mA and maintain 0.8 volts down-level.
Input from address 278/378/3BC Hex
This command presents the processor with data present on the pins associated with the corresponding output address. This should normally reflect the exact value that was last written. If an external device should be driving data on these pins (in violation of usage groundrules) at the time of an input, this data will be ORed with the latch contents.
Input from address 279/379/3BD Hex
This command presents realtime status to the processor from the pins as follows.
Bit 7 6 5 4 3 2 1 0
Pin 11 10 12 13 15 - - -
Input from address 27A/37A/3BE Hex
This instruction causes the data present on pins 1, 14, 16, 17 and the IRQ bit to be read by the processor. In the absence of external drive applied to these pins, data read by the processor will exactly match data last written to the corresponding output address in the same bit positions. Note that data bits 0-2 are not included. If external drivers are dotted to these pins, that data will be ORed with data applied to the pins by the output latch.
Bit 7 6 5 4 3 2 1 0
Pin - - - IRQ ~17 16 ~14 ~1
enable
state assumed after processor reset
0 1 0 1 1
Registers & Pinouts
Registers (- unavailable)
Pinouts
Register DB-25 I/O
Signal Name Bit Pin Direction
=========== ======== ===== =========
-Strobe ¬C0 1 Output
+Data Bit 0 D0 2 Output
+Data Bit 1 D1 3 Output
+Data Bit 2 D2 4 Output
+Data Bit 3 D3 5 Output
+Data Bit 4 D4 6 Output
+Data Bit 5 D5 7 Output
+Data Bit 6 D6 8 Output
+Data Bit 7 D7 9 Output
-Acknowledge S6 10 Input
+Busy ¬S7 11 Input
+Paper End S5 12 Input
+Select In S4 13 Input
-Auto Feed ¬C1 14 Output
-Error S3 15 Input
-Initialize C2 16 Output
-Select ¬C3 17 Output
Ground - 18-25 -
(Note again that the S7, C0, C1 & C3 signals are inverted)
IBM-PC Parallel Printer Port Female DB-25 Socket external Pin layout
______________________________________________________
/ \
\ 13 12 11 10 9 8 7 6 5 4 3 2 1 /
\ /
\ 25 24 23 22 21 20 19 18 17 16 15 14 /
\________________________________________________/
So it's also the Pin layout on the solder side of the Male DB-25 Cable Connector that plugs into it.
Microsoft Visual C/C++ provides access to the I/O ports on the 80x86 CPU via the predefined functions _inp / _inpw and _outp / _outpw.
int _inp(unsigned portid); /* returns a byte read from the I/O port portid */
unsigned _inpw(unsigned portid); /* returns a word read from the I/O port portid */
int _outp(unsigned portid, /* writes the byte value to the I/O port portid */
int value); /* returns the data actually written */
unsigned _outpw(unsigned portid, /* writes the word value to the I/O port portid */
unsigned value); /* returns the data actually written */
portid can be any unsigned integer in the range 0-65535
#include /* required only for function declarations */
#define Data 0x378
#define Status 0x379
#define Control 0x37a
int Bits, /* 0 <= Bits <= 255 */
Dummy;
Dummy = _outp(Data,Bits); /* output data */