Sei sulla pagina 1di 2

STANDARD PARALLEL PORT (SPP) CHEATSHEET

by Roger Guachalla Narváez xoroger@yahoo.es

Printer Cable Connector: [ DB25 ]-------------[ DB36 ]

+------------------------------------------------------+
¦ Register ¦Bit ¦Dir¦Logic¦DB25#¦DB36#¦ Description ¦
+----------+----+---+-----+-----+-----+----------------¦
¦DR:Data ¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ ¦ b0 ¦ oo¦ . ¦ 2 ¦ 2 ¦ Data0 ¦
¦lpt1: ¦ b1 ¦ oo¦ . ¦ 3 ¦ 3 ¦ Data1 ¦
¦ 378h ¦ b2 ¦ oo¦ . ¦ 4 ¦ 4 ¦ Data2 ¦
¦ 888d ¦ b3 ¦ oo¦ . ¦ 5 ¦ 5 ¦ Data3 ¦
¦ ¦ b4 ¦ oo¦ . ¦ 6 ¦ 6 ¦ Data4 ¦
¦lpt2: ¦ b5 ¦ oo¦ . ¦ 7 ¦ 7 ¦ Data5 ¦
¦ 278h ¦ b6 ¦ oo¦ . ¦ 8 ¦ 8 ¦ Data6 ¦
¦ 632d ¦ b7 ¦ oo¦ . ¦ 9 ¦ 9 ¦ Data7 ¦
+----------+----+---+-----+-----+-----+----------------¦
¦SR:Status ¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ ¦ b0 ¦ - ¦ - ¦ - ¦ - ¦ - ¦
¦lpt1: ¦ b1 ¦ - ¦ - ¦ - ¦ - ¦ - ¦
¦ 379h ¦ b2 ¦ - ¦ - ¦ - ¦ - ¦ - ¦
¦ 889d ¦ b3 ¦ ii¦ . ¦ 15 ¦ 32 ¦ Error ¦
¦ ¦ b4 ¦ ii¦ . ¦ 13 ¦ 13 ¦ Select ¦
¦lpt2: ¦ b5 ¦ ii¦ . ¦ 12 ¦ 12 ¦ Paper Error ¦
¦ 279h ¦ b6 ¦ ii¦ . ¦ 10 ¦ 10 ¦ Acknowledge ¦
¦ 633d ¦ b7 ¦ ii¦ * ¦ 11 ¦ 11 ¦ Busy ¦
+----------+----+---+-----+-----+-----+----------------¦
¦CR:Control¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ ¦ b0 ¦ io¦ * ¦ 1 ¦ 1 ¦ Strobe ¦
¦lpt1: ¦ b1 ¦ io¦ * ¦ 14 ¦ 14 ¦ Automatic Feed ¦
¦ 37Ah ¦ b2 ¦ io¦ . ¦ 16 ¦ 31 ¦ Init ¦
¦ 890d ¦ b3 ¦ io¦ * ¦ 17 ¦ 36 ¦ Select In ¦
¦ ¦ b4 ¦ - ¦ - ¦ - ¦ - ¦ - ¦
¦lpt2: ¦ b5 ¦ - ¦ - ¦ - ¦ - ¦ - ¦
¦ 27Ah ¦ b6 ¦ - ¦ - ¦ - ¦ - ¦ - ¦
¦ 634d ¦ b7 ¦ - ¦ - ¦ - ¦ - ¦ - ¦
+----------+----+---+-----+-----+-----+----------------¦
¦ GND ¦ ¦ - ¦ - ¦18-25¦ - ¦ Ground ¦
+----------+----+---+-----+-----+-----+----------------¦
¦ * VCC ¦ - ¦ - ¦ - ¦ - ¦ - ¦ - ¦
+------------------------------------------------------+
* VCC: There is NO +5V VCC output on Centronics Parallel Port

b7 b6 b5 b4 b3 b2 b1 b0
+-------------------------------+
DR:Data ¦ oo¦ oo¦ oo¦ oo¦ oo¦ oo¦ oo¦ oo¦
378h ¦ . ¦ . ¦ . ¦ . ¦ . ¦ . ¦ . ¦ . ¦
+---+---+---+---+---+---+---+---¦
SR:Status ¦ ii¦ ii¦ ii¦ ii¦ ii¦ - ¦ - ¦ - ¦
379h ¦ * ¦ . ¦ . ¦ . ¦ . ¦ - ¦ - ¦ - ¦
+---+---+---+---+---+---+---+---¦
CR:Control ¦ - ¦ - ¦ - ¦ - ¦io ¦io ¦io ¦io ¦
37Ah ¦ - ¦ - ¦ - ¦ - ¦ * ¦ . ¦ * ¦ * ¦
+-------------------------------+

Where:
ii : Input
oo : Output
io : Input/Output
. : Direct Logic
* : Inverse Logic
- : Not Aplicable
bn : bit n [n 0..7]

Note:
Before performing any READ operation on the CR (Control Register),
all of its port bits must have a 5 volt output.( i.e a $04 must
be writen to the CR register first! (In Pascal: Port[$37A]:=$04) )
Source code for using the SPP in different languages:

Turbo C Turbo Pascal Visual Basic Assembler


+---------------------------------------------------------------------------------------+
¦ Output ¦ outportb(#port,wdata)¦ Port[#port]:=wdata ¦ Out #port,wdata ¦ MOV DX,#port ¦
¦ ¦ ¦ ¦ ¦ MOV AL,wdata ¦
¦ ¦ ¦ ¦ ¦ OUT DX,AL ¦
+--------+----------------------+--------------------+-------------------+--------------¦
¦ Input ¦ rvar=inportb(#port) ¦ rvar:=Port[#port] ¦ rvar = Inp(#port) ¦ MOV DX,#port ¦
¦ ¦ ¦ ¦ ¦ IN AL,DX ¦
¦ ¦ ¦ ¦ ¦ MOV rvar,AL ¦
+---------------------------------------------------------------------------------------+

Where:
wdata: write data
rvar : read variable
#port: port number

PARALLEL PORT IN BIDIRECTIONAL MODE (Needs BIOS configuration)

b7 b6 b5 b4 b3 b2 b1 b0
+-------------------------------+
DR:Data ¦ io¦ io¦ io¦ io¦ io¦ io¦ io¦ io¦
378h ¦ . ¦ . ¦ . ¦ . ¦ . ¦ . ¦ . ¦ . ¦
+---+---+---+---+---+---+---+---¦
CR:Control ¦ - ¦ - ¦DIR¦ - ¦io ¦io ¦io ¦io ¦
37Ah ¦ - ¦ - ¦ ¦ - ¦ * ¦ . ¦ * ¦ * ¦
+-------------------------------+
Where:
DIR: CR's DIRection control for DR

DIR DR Mode
+------------+
¦ 0 ¦ Output ¦
+---+--------¦
¦ 1 ¦ Input ¦
+------------+

Visual Basic ***


Example to Output data

Out &H37A, 0 'Configure DR as output (DIR=0)


Out &H378, wdata 'writes data

Example to Input data

Out &H37A, 32 'Configure DR as input (DIR=1)


rvar = Inp(&H378) 'reads data

Delphi ***
Example to Output data

Out32($378,$53); // Writes $53 through DR

Example to Input data

edit1.Text:=IntToHex(Inp32($378),2); // Shows Read value from $378 in Edit1

*** After download inpout32.dll copy it to Windows\system32\

Potrebbero piacerti anche