B&B Electronics Parallel Port Input/Output Converter PPIO User Manual

Page 17

Advertising
background image

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

15

Notice that in the binary representation of the mask value, line

zero’s mask has bit number zero set, and line one’s mask has bit
number one set, etc. So, instead of retrieving the mask value from a
table, the value is calculated by shifting 00000001b (1 decimal, 01
hexadecimal) right the same number of times as the desired line
number. Once the mask value is calculated, it is bitwise ANDed with
Input_Byte. If the resulting value is non-zero, the line is ON and a
boolean TRUE is returned, otherwise a boolean FALSE is returned.

For example:
Line_Number = 3
Status Register Value = 01010101b
Control Register Value = 10101010b

01010101b (Status Register)

AND

11110000b (F0h mask)

01010000b

10101010b (Control Register)

AND

00001111b (0Fh mask)

00001010b——>

OR

00001010b

01011010b


00000001b (1 decimal)
shift-right 3(Line_Number)= AND

00001000b(bit mask)

00001000b

The function, Output_Bit, returns the status of the selected

output line. The function is defined as:

FUNCTION Output_Bit (Bit_Number:BYTE) : BYTE;
BEGIN

If ( ( Output_Byte AND (1 SHL Bit_Number ) ) = 0 THEN

Output_Bit : = 0

ELSE

Output_Bit : = 1;

END; {Output_Bit}

Advertising