First page Back Continue Last page Overview Graphics
In embedded systems programming, it is very important to isolate bits and to check only the desired bits.
A logical AND is used to mask off and check bits.
- port_t: equ $ae
- lp: ldaa port_t
- anda #%00001000
- bne lp
- What will cause the above program to break out of the loop? _______________
The code shown in the example loops until bit 3 of port T goes low. The code is checking bit 3 and as long as it is 1 the program loops. Other bits of port T will not have any affect on the looping. When checking a bit, put a 1 in the bit position of the bit you are trying to check. Put zeros in the bit positions not being checked.
How would the program be changed to wait for bit 3 to go high? ________________
A possible application of the above code could be waiting for an analog-to-digital (A/D) conversion to complete by checking a converter status bit. In a typical system, the conversion will be started (by setting/clearing a bit) followed by code that waits (by looping and examining a bit) for the conversion to complete.