Parallel Printer Port Information:

Terry King 11/04/97  tking@together.net                REV 1.20    11/04/97

ADDRESSES:
                                        "BNB"     BASE     BASE ADDR  BASE ADDR
                                       SOFTWARE   ADDRESS    + 1        + 2
                                         CALLS
                                          IT:     "Data    "Printer   "Printer
                                                   Latch"   Status"    Control"

IBM "Parallel Card" or "Printer Adapter" LPT1     x0378    x0379      x037A
    and most "multifunction" cards
    (USUALLY seen by DOS as "LPT1")

IBM "Parallel Card" or "Printer Adapter" LPT2     x0278    x0279      x027A
    and most "multifunction" cards
    (USUALLY seen by DOS as "LPT2")

IBM "Monochrome and Printer Card"        LPTM     x03BC    x03BD      x03BE
    and most IBM PS/2 System boards
    (USUALLY seen by DOS as "LPT1", AND
    the two addresses above THEN become
    "LPT2" and "LPT3" respectively)

NOTE: Most 'BitNByte' and 'BitMachine' programs default to LPT2 (x0278)
      but will take a command-line parameter of LPT1, LPT2 or LPTM and
      operate at those addresses without further modification.
  EXAMPLE:  'bitmach lpt1'   will run the BitMachine program and use LPT1

OR: at DOS prompt or in AUTOEXEC: SET PARPORT=LPT1 (or LPT2 or LPTM)

          REGISTER BIT ASSIGNMENTS AND CONNECTOR PIN NUMBERS:
---------------------------------------------------------------------------
NOTE: This is detailed information that you don't NEED to use the software!

BITNBYTE   CARD REGISTER     PARALLEL         N O T E S :
SIGNAL     NAME AND BIT #    PRINTER PORT
NAME:      (LPT1 addr shown) DB-25 PIN #
--------   ---------------   ------      ----------------------------------
           "DATA LATCH"                  This is normally an OUTPUT. However
           (OUT x0378)                   PS/2's and modified cards can make
Out0       Bit 0             Pin 2       these pins readable as INPUTS
Out1       Bit 1             Pin 3
Out2       Bit 2             Pin 4       Usually an IN of this address gives
Out3       Bit 3             Pin 5       a readback of the last data put OUT
Out4       Bit 4             Pin 6
Out5       Bit 5             Pin 7
Out6       Bit 6             Pin 8
Out7       Bit 7             Pin 9
--------   ---------------   ------      ----------------------------------
           "PRINTER STATUS"              This is ALWAYS an INPUT. An output
           (IN  x0379)                   to this address has NO effect.
           Bit 0           UNUSED        NOTE: some bits are INVERTED and their
           Bit 1           UNUSED              bit numbers are followed by a -
           Bit 2           UNUSED        NOTE: "BITNBYTE" software combines
In5        Bit 3             Pin 15            these bits with ones from the
In3        Bit 4             Pin 13            "Printer Control" readback to
In2        Bit 5             Pin 12            provide users with 8 INPUTS.
In0        Bit 6             Pin 10
In1        Bit 7 -           Pin 11
--------   ---------------   ------      ----------------------------------
           "PRINTER CONTROL"             This is can be either INPUT or OUTPUT
           (OUT x037A)                   but is "Open Collector" and some bits
           Bit 0 -     (SET TO:  0 )     are INVERTED.
           Bit 1 -     (SET TO:  0 )     NOTE: "BITNBYTE" software sets needed
           Bit 2 +     (SET TO:  1 )           bits so they are inactive as
           Bit 3 -     (SET TO:  0 )           outputs to allow use of this
           Bit 4  (IRQ: DISABLED 0 )           port in INPUT mode (See below).
           Bit 5           UNUSED
           Bit 6           UNUSED
           Bit 7           UNUSED
--------   ---------------   ------      ----------------------------------
           "PRINTER CONTROL(Readback)"   This is can be either INPUT or OUTPUT
           (IN  x037A)                   but is "Open Collector" and some bits
           Bit 0 - (RESERVED)Pin  1      are INVERTED.
In4        Bit 1 -           Pin 14      NOTE: "BITNBYTE" software combines
In6        Bit 2             Pin 16            these bits with ones from the
In7        Bit 3 -           Pin 17            "Printer Status" port to
           Bit 4   (IRQ ENABLE Readback)       provide users with 8 INPUTS.
           Bit 5           UNUSED
           Bit 6           UNUSED
           Bit 7           UNUSED   

BITNBYTE SOFTWARE EXTERNAL CONNECTION PIN NUMBERS
----------------------------------------------------------------------

BITNBYTE  PARALLEL         N O T E S :
SIGNAL    PRINTER PORT
NAME:     DB-25 PIN #
--------  ------      ----------------------------------


Out0      Pin 2
Out1      Pin 3
Out2      Pin 4
Out3      Pin 5
Out4      Pin 6
Out5      Pin 7
Out6      Pin 8
Out7      Pin 9

In0      Pin 10
In1      Pin 11
In2      Pin 12
In3      Pin 13
In4      Pin 14
In5      Pin 15
In6      Pin 16
In7      Pin 17       NOTE: Pins 18 thru 25 are GROUND


BITNBYTE SOFTWARE INTERNAL DESIGN: PARALLEL PORT DATA VALUES
----------------------------------------------------------------------

Algorithm:

Port[PrinterControl] := $04 ;    { Set output port to prepare for input      }

                                  { (Bits Inverted)    -     -       -   =$92}
                                    (Bit Position)     7 6 5 4   3 2 1 0

StatPort := Port[PrinterStatus]   ; (Bit Locations)    1 0 2 3   5
CtrlPort := Port[PrinterControl]  ; (Bit Locations)              7 6 4
PortWork := 0;
PortWork := (StatPort SHR 6) ;                             {Get Bit 0 and 1}
PortWork := PortWork OR ((StatPort AND $20) SHR 3) ;       {Get Bit 2}
PortWork := PortWork OR ((StatPort AND $10) SHR 1) ;       {Get Bit 3}
PortWork := PortWork OR ((CtrlPort AND $02) SHL 3) ;       {Get Bit 4}
PortWork := PortWork OR ((StatPort AND $08) SHL 2) ;       {Get Bit 5}
PortWork := PortWork OR ((CtrlPort AND $0C) SHL 4) ;       {Get Bit 6 and 7}
PortWork := PortWork EOR $6D;  {Fix both minus-true inputs and Inverted Bits }

