You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
VALUE 00111010 00011010 11110000 00011111<br />
MASK 00100000 00100000 00100000 00100000<br />
RESULT 00100000 00000000 00100000 00000000<br />
Fig. 4-3. Example of AND operation in which eight bits of information are<br />
operated on.<br />
"mask," and the "B" bit as information or data. When the mask is<br />
zero, the result is a zero. When the mask is a one, the data is passed<br />
ough the gate. In this way, selected bits may be masked, while<br />
hers are "passed through" the mask. If, for example, we wished to<br />
eek the state of bit D5 in the data. word 00111010, a mask of<br />
100000 could be used. The mask is '}NOOd with the data word, as<br />
own in Fig. 4-3, for several different data words. In all cases, the<br />
gic state of D5 was passed through to bit D5 in the result. All of<br />
e other bits were masked, or set to zero. In this way, the total re<br />
. lt was zero when bit D5 was zero, and the result was nonzero when<br />
't D5 was a one. This could be used as the basis for decision making<br />
ps in a program. You must remember to convert the masks to their<br />
.eimal equivalent before trying to use them in a BASIC program .<br />
. the case of bit D5, the mask would be converted to 32.<br />
FLAG-DETECTING SOFTWARE<br />
.Once an interface has been constructed so that the states of the<br />
ious flags may be detected, as shown in Fig. 4-4, software may be<br />
d to make decisions based upon the states of the flags.<br />
In some dialects of BASIC, there are logical operations that will<br />
rform bit-by-bit AND operations, such as the ones shown in Fig .<br />
. In these cases, simple expressions may be used in BASIC pro-<br />
INPUT DEVICE<br />
ONE·BIT INPUT PORT .---- RD 49321<br />
J"L<br />
..<br />
READY/BUSY 1-----t >-----.<br />
D7<br />
t---+--D7<br />
'TO DATA<br />
BUS<br />
DO t----t<br />
1---DO<br />
.__..n... _ __ RD 49320<br />
Fig. 4-4. Complete interface in which the flag is detected by software.<br />
59