Page 67 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 67

44                                            Chapter 2 The Instruction Set

















                                 Figure 2.16. Decision Tree
        keep you from confusing them with the signed ones, for example, BLO for "branch if
        lower," BLS for "branch if lower or the same," BHI for "branch if higher," and BHS for
        "branch if higher or the same." Notice that BLO is the same instruction as BCS, and BHS
        is the same instruction as BCC. Here then is an example of two different mnemonics
        describing the same instruction, something that is sometimes warranted when the
        programmer will be using the same instruction with two distinct meanings.
            Figure 2.16 illustrates a flow chart of several tests that form a decision tree. In
        Figure 2.17 and subsequent figures, labels are written left justified and end in a colon.
        Upon entry at label LO, location $801 is tested; if it is positive, go to L2 if location
        802's unsigned value is greater than $32, otherwise go to L3. If location $801 is
        negative, go to L4 if location $801 bit 2 is zero, otherwise go to L5. The program
        segment in Figure 2.17 implements this decision tree.
            Do not be concerned about calculating the relative branch offsets; §3.3 will discuss
        this calculation. One should consult Table 2.8 for a while to make sure that the correct
        branch is being chosen. For example, to test a register value greater than or equal to a
        memory value, you might be tempted to use the simple branch BPL for signed numbers
        instead of BGE. The problem is that you want the branch test to work even when
        subtraction or comparison generates a signed overflow. But this is just exactly when the






















                        Figure 2.17. Program Segment for a Decison Tree
   62   63   64   65   66   67   68   69   70   71   72