Page 136 - Understanding Automotive Electronics
P. 136
2735 | CH 4 Page 123 Tuesday, March 10, 1998 11:06 AM
MICROCOMPUTER INSTRUMENTATION AND CONTROL 4
Figure 4.15
Assembly Language
Subroutines
FPO
The use of a mask allows The operation of the program is as follows. The accumulator is loaded with
the microcomputer to the contents of the memory location SEAT. Note in Figure 4.12 that the two
separately examine two digital logic input signals, A and B, have been gated into bits 0 and 1, respectively,
or more digital signals of the buffer that occupies the memory location labeled SEAT. Bit 0 is high when
(bits) occupying the someone is sitting in the driver’s seat. Bit 1 is high when the driver’s seat belt is
same 8-bit byte. fastened. Only these two bits are to be ANDed together; the other six are to be
ignored. But there is a problem because both bits are in the same 8-bit byte and
there is no single instruction to AND bits in the same byte. However, the two bits
can be effectively separated by using a mask.
Masking
During a mask opera- Masking is a technique used to allow only selected bits to be involved in a
tion, the accumulator desired operation. Since the buffer contents have been loaded into the
contents are ANDed accumulator, only bits 0 and 1 have meaning, and these two bits are the only
with the mask value, ones of importance that are to be kept in the accumulator. To do this, the
which has a zero in each accumulator is ANDed with a constant that has a zero in every bit location
bit location except for the except the one that is to be saved. The binary constant in line 2 of Figure 4.15a
bit(s) to be saved. The (00000001) is chosen to select bit 0 and set all others to zero as the AND
saved, or masked, bit(s) instruction is executed. The ANDing procedure is called masking because a
comes through mask has been placed over the accumulator that allows only bit 0 to come
unchanged, but all others through unchanged. If bit 0 was a logical 1, it is still a logical 1 after masking. If
are set to zero. bit 0 was a logical 0, it is still a logical 0. All other bits in the accumulator now
contain the correct bit information about bit 0.
UNDERSTANDING AUTOMOTIVE ELECTRONICS 123