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

3.1 OP Code Byte Addressing Modes                                    59

            Other modes allow the data to be variable, as opposed to the fixed data. The 6812
         has two such modes, direct and page zero, to allow for accessing any word in memory,
         but they allow accessing the most common words more efficiently.
            We introduced the direct mode in Chapter 1, and we merely review it here. It is
         really the only mode required for any program that we would write if we were not
         concerned about efficiency and if we permitted the program to modify one of its own
         instructions. Indeed, that was the way the first computer was programmed. However, if
         one examines a program that changes its instructions, it is very unclear. An example of
         this type of program, using what is called self-modifying code, is given in the problems
         at the end of this chapter. To avoid self-modifying code and to improve efficiency, other
         addressing modes will be introduced. In the direct mode, the address of the operand or
         result is supplied with the instruction. For example, as discussed before,
                                       LDAA $803

         puts the contents of location $803 into accumulator A. The opcode for this instruction is
         $B6, and the instruction is stored in memory as the sequence:







         In the direct mode, a full 16 bits are always used to describe the address even though the
         first byte may consist of all zeros. Unfortunately, when they first developed the
         MC6800, a predecessor of the 6812, Motorola called page zero addressing "direct
         addressing," most likely because they envisioned only a 256-byte RAM. Motorola called
         direct addressing "extended addressing." This nonstandard use of the term has continued
         through Motorola's 8-bit and 16-bit microcontrollers and confuses everyone who uses or
         studies a variety of machines, including other Motorola microprocessors. Because we
         intend to teach general principles, using the 6812 as an example rather than teaching the
         6812 only, we will stick to the traditional terra. But when you read Motorola's literature,
        remember to translate their "extended addressing" into "direct addressing." Do not confuse
        Motorola's "direct addressing" with our use of the term "direct addressing."
            Experience has shown that most of the accesses to data are to a rather small number
        of frequently used data words. To improve both static and dynamic efficiency, the 6812
        has a compact and fast version of one-level addressing to be used with the most
        commonly accessed data words. The page zero mode is an addressing mode that forms
        the effective address by forcing the high-order byte to be 0 while the lower-order byte is
         supplied by the eight bits in the instruction. For example,
                                       LDAA $67

        will put the contents of location $0067 into accumulator A. This instruction is stored in
        memory as:
   77   78   79   80   81   82   83   84   85   86   87