B&B Electronics Parallel Port Input/Output Converter PPIO Benutzerhandbuch

Seite von 34
14 
PPIO2899 Manual 
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104 
 
 
The parallel port’s status register stores the upper nibble (four 
bits) of the input line status. Since the smallest value that can be 
read from the port is a byte, some work must be done to get only the 
upper nibble’s value. We read a byte from the status register and 
bitwise AND it with F0h (240 decimal, 11110000 binary). This sets 
the lower nibble of the byte to zero. 
 
 
The parallel port’s control register stores the low nibble of the 
input line status. A method, similar to the one used to get the high 
nibble, extracts the low nibble. We read a byte from the control 
register and bitwise AND it with 0Fh (15 decimal, 00001111 binary). 
This sets the upper nibble of the byte to zero. 
 
 
 
Now, combine both bytes into one value by bitwise ORing them 
together. This value is stored in the variable Input_Byte. At this point, 
the upper nibble of Input_Byte is the same as the upper nibble of the 
status register and the lower nibble of Input_Byte is the same as the 
lower nibble of the control register. 
 
 
 
To return the status of a specific line, a test is done to determine 
the state of the line’s corresponding bit stored in Input_Byte. To 
determine the bit’s state, all other bits of Input_Byte are set to zero. 
This is done by bitwise ANDing Input_Byte with the mask value of 
the desired line shown in the following table. 
 
 
Mask Value 
Line 
Hex 
Decimal 
Binary 
01h 
00000001 
02h 
00000010 
04h 
00000100 
08h 
00001000 
10h 
16 
00010000 
20h 
32 
00100000 
40h 
64 
01000000 
80h 
128 
10000000