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
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)
00000001b (1 decimal)
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}
PPIO2899 Manual | 15 |
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph