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

1.6 Summary And Further Reading                                      21


        into both accumulators A and B. Reading a 16-bit word from an odd effective address in
        the internal memory can be done in one memory cycle; the even-byte memory bank can
        decode a memory address one above the memory address of the odd bank, and the switches
        next to the accumulators can reroute the bytes into the correct accumulators. However,
        reading a 16-bit word from an odd address in the external memory is done in two memory
        cycles; the byte at the lower address is read first, as discussed in the previous paragraph,
        then the byte at the higher address is read.
            Consider writing a 16-bit word from accumulator D. If the address is even, simply
        write a byte from both accumulators A and B through both data buses into both banks. If
        the address is odd, writing 16 bits is easily done in the internal memory; each byte is
        written, but at different addresses in the even and odd byte memory banks. But if the
        address is odd, writing 16 bits into the external memory is done by writing the lower
        addressed byte first in one memory cycle, then writing the other byte in the next cycle.
            Each access to read or write a byte through an 8-bit narrow bus takes one memory
        cycle. Each access to read or write a 16-bit word uses two memory cycles.
            Cycle counts in the CPU12RG/D manual Instruction Set Summary are for
        instructions and data read and written in internal RAM. These counts may be higher
        when instructions and data are read from or written into external RAM.
            At the beginning of this chapter, we proposed to show you how an instruction is
        executed in a microcontroller. But from this discussion of 6812 memory operations, you
        see that a simple operation becomes significantly more complex when it is implemented
        in a state-of-the-art microcontroller. Just reading a 16-bit word from memory might be
        done several ways depending on where the word is located, inside or outside the
        microcontroller, or using an even or an odd address. But from the point of view of how
        an instruction is executed in the 6812, a simple model that explains the concept fully is
        better than the fully accurate model that accounts for all the techniques used to
        implement the operation; we simply state that a 16-bit word is read from memory. The
        reader should understand how instructions are executed, but from now on in this book,
        we will use a simplified model of the hardware to explain how an instruction is actually
        implemented in hardware (in an idealized microcontroller, rather than the real 6812).



        1.6 Summary and Further Reading

        In this chapter we examined the computer and the instruction in some detail. You should
        be prepared to study each of the instructions in the 6812 in the following two chapters
        with respect to the details that we introduced for the load instruction in this chapter. We
        will expand the ideas of programming, introduced at the end of this chapter, as we
        progress through the book. Many questions may remain unanswered, though, after
        reading this chapter. We want you to continue reading the following chapters as we
        discuss the way to use this marvelous tool.
            In this book, we use Motorola's CPU12RG/D manual to provide essential
        information needed to write and read machine code for the 6812 in compact and neat
        form. This manual is a summary of key tables and figures in the manual
        CPU12RM/AD, which contains complete information on the execution of each
        instruction. Additionally, there is a manual for the 'B32, M68HC912B32TS/D, and a
   39   40   41   42   43   44   45   46   47   48   49