Page 68 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 68
2.5 Control Instructions 45
Table 2.9. Other Control Instructions
sign is incorrect; then using BPL cannot be used to replace BGE. Thus, after a compare
or subtract between signed numbers, use BGE rather than BPL. You might also be
tempted to use BPL for the unsigned test. However, if accumulator A has $80 and the
immediate operand is $32, then N = 0 after performing the test. Thus BPL takes the
branch, even though it should not because $32 is not higher than $80. Thus after an
unsigned number comparison or subtraction, use BHS rather than BPL.
A rather amusing instruction, BRN L, which "branches never" regardless of the
location L, is the opposite to the "branch always" instruction. It is useful because any
branching instruction can be changed to a BRA or BRN instruction just by changing an
opcode byte. This allows a programmer to choose manually whether a particular branch
is taken while he or she is debugging a program.
Figure 2.18. Program Segment for Setting, Clearing, and Testing of a Bit