The Parallel Port
The parallel port on the PC is usually called the "printer port" because
it is most often used to connect to a printer. If you look
at this port's connector on the back of the PC you will see 25 holes
which mate with the 25 pins of the printer cable. We are only interested
in 8 of these (the others are used for such things as letting the printer
signal the PC when you're out of paper; some are not used at all).
The 8 pins (wires) that we will use correspond exactly to the 8 bits in
a byte. In fact, you can think of these 8 wires as a realworld byte!
There are exactly 2^8 (2 to the 8th power, or 256) possible combinations
of electrical "on's" and "off's" that can exist over these 8 wires at any
one time. When we send a byte to the parallel port, its bits are
simply connected to these 8 wires, which happen to reside on pins 29 on
the connector. Bit #0 is connected to wire #2, in order up to bit
#7 connected to wire #9.
How exactly do we send a byte to the parallel port?
Just like sending a letter to someone, you need to know their address.
In the PC, everything that is connected to it (like the harddrive, the
keyboard, etc.) has an address. The parallel port's is usually 888
(more about this later). Once we know the address, we can then
send any of 256 possible bytevalues to the port. In the PC,
we cannot send less information than a single byte's 8 bits to a port.
Numbers are the easiest way to refer to a byte's value, and so we can choose
any whole number from 0 to 255. It might seem easier if this were
1 to 256, but we will see why 0255 makes more sense. The BASIC command
"out 888, 255" means: send to address 888 (the parallel port) a byte whose
value is 255. By sending other byte values we can change the
voltage (on or off) of every one of those 8 wires!
How do we turn on or off a specific wire's voltage, using a byte value?
Here is where a bit of mathematics helps out. We are used to counting
by using the normal digits 0,1,2,3,4,5,6,7,8,9. This is called "base10,"
because there are 10 different symbols. But in the computer, there
are only two symbols 0,1  which means that the computer uses base2.
Just like with base10, when we want to write a number that is larger than
the number of symbols we have, we use placement strategy. "15" means
(1x10^1)+(5x10^0). To write the same number in base2 we cannot use
a "5" (which has no meaning remember, only 0 and 1 have meaning in base2).
So we use the same strategy:
8 + 4
+ 2 +
1
1111 = (1x2^3 )+(1x2^2 )+(1x2^1 )+(1x2^0) . Notice that
2^0 and 10^0 are both = 1.
Another example:
255 = (2x10^2)+(5x10^1)+(5x10^0) in base10.
But in base2, we would write:
128 + 64 +
32 + 16 +
8 + 4
+ 2 +
1
11111111 = (1x2^7 )+(1x2^6 )+(1x2^5 )+(1x2^4)+(1x2^3 )+(1x2^2 )+(1x2^1
)+(1x2^0)
From this example, it should make sense that if we want all of the 8
wires to be on (= 1), then we send a value of 255. The reason we,
as humans, do not use base2 directly is that it is very difficult for
us to keep track of the placement of all those 1's and 0's in our heads.
Computers have no trouble with this!
More examples:
BASIC command, using base10 byte value 
base2 byte value 
bit values in the byte 
real world effect (voltage of wires 29 of the connector) 
out 888, 0 
0 
00000000 
all wires lo 
out 888, 1 
1 
00000001 
wire #2 hi only 
out 888, 2 
10 
00000010 
wire #3 hi only 
out 888, 4 
100 
00000100 
wire #4 hi only 
out 888, 8 
1000 
00001000 
wire #5 hi only 
out 888, 16 
10000 
00010000 
wire #6 hi only 
out 888, 32 
100000 
00100000 
wire #7 hi only 
out 888, 64 
1000000 
01000000 
wire #8 hi only 
out 888, 128 
10000000 
10000000 
wire #9 hi only 
out 888, 2^7 
same 
same 
same 




out 888, 3 
11 
00000011 
wires #2 and #3 hi 
out 888, 1+2 
same 
same 
same 




out 888,15 
1111 
00001111 
#2, #3, #4, #5 hi 
All possible combinations of wire "ons and offs" can be achieved using
the byte values from 0 to 255.
It is useful to refer to the bit numbers as running from 07 (instead
of 18). This is because these numbers exactly correspond to the
power of two needed to turn that bit on:
out 888, 2^3 >turns bit #3 on (in BASIC, ^ means "raised
to the power of")
out 888, 2^1 + 2^5 >turns bits #1 and #5 on
We must be careful to keep our numbers straight bit numbers
refer to their place in the byte; wire numbers refer
to their place on the connector.
We are now ready to connect what we have learned to the real world...
next the Litbit
home
Copyright © 2000 Bruce Shapiro