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

352                                        Chapter 12 Other Microcontrollers


        instructions. For example, the 6812 instruction LBCC can be replaced by the 6811
        sequence
                                        BCS *+5
                                       JMP L2
            The 6812 extended arithmetic instructions _ EMUL, EMULS, EDIV, ED1VS,
        IDIVS, and EMACS _ are not 6811 instructions. These have to be implemented as
        subroutines. Other arithmetic instructions, MUL, FDIV, and IDIV, are quite a bit slower
        in the 6811. Fuzzy logic instructions MEM, REV, REVW, WAV, and similar
        instructions —ETBL, MAXA, MAXM, MINA, MINM, EMAXD, EMAXM, EMIND, and
        EMINM—are not 6811 instructions; they are implemented as subroutines or macros.
        6812 control instructions—CALL, DBNE, DBEQ, IBNE, IBEQ, TBNE, and TBEQ —are
        not 6811 instructions, so a modified strategy is used to control loops and effect
        conditional expressions. Finally, the 6811 does not have the MOVE, MOVM, PSHC,
        PULC, and SEX instructions and does not have the full capabilities of TFR and EXG
        instructions.
            With these modifications, you can rewrite a program written for the 6812. Try a few
        programs. Scan through the earlier chapters, and pick programs you have already written.
        Rewrite them for the 6811. It is not too hard. However, we caution you that each
        computer has its strong points, and writing a good program by adapting a program from
        another computer for a new computer does not take full advantage of the strong points of
        the latter. In the 6811, for instance, ABX is one byte, takes three cycles, and adds B as an
        unsigned 8-bit number; its equivalent in the 6812, LEAX B,X, is two bytes, takes two
        cycles, and adds B as a signed 8-bit number. The 6811 should use programs where an
        unsigned index is added to the X register, in preference to those programs where a signed
        index is added to X. You have to be more careful in the 6811 to organize your data to use
        only positive offsets from X. For instance, you may select to implement a second stack
        in the same direction as the hardware stack, to avoid using a negative offset to a stack
        that moves in opposite direction to the hardware stack that shares its buffer space.
            Your 6811 programs can be tested using the debugger MCUez or Hi Ware, which can
        be implemented for the 6811 using a PC. We strongly recommend that you try your
        programs on such a system to get a feeling for the 6811.


         12.2 The 6808

        The 6808 is upward compatible from the 6805 (described in the next section), which it is
         intended to replace, while having the essential capabilities that are needed to implement
        code generated by a C compiler. Moreover, the 6808 is likely to replace the 6805 in
        newer designs and is more similar to the 6812, so we study it before the 6805. We will
        show how you might program these microcomputers by comparing them to the 6811
        and 6812.
             Maintaining compatibility will be discussed after the 6805 is presented. We focus
        on the differences between the 6812 and the 6808, so that you can adapt your 6812
        programs to the 6808. Registers for the 6808 are like those in the 6811, but there is
        neither accumulator B nor index register Y (see Figure 12.2, and see its condition codes
        in Figure 12.3).
   370   371   372   373   374   375   376   377   378   379   380