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

364                                        Chapter 12 Other Microcontrollers


         is a list of data and/or address registers; #<data> is an immediate operand; <ea> is an
        addressing mode; <label> is a label on a program statement; and cc is a condition code
         and value.
            The 68300 effective address can be the sum of three values. The sum of a general
        register (which is any address or data register), an address register, and a signed 16-bit
        offset is used as the effective address in base index addressing.
            Several special move instructions are provided. A MOVE instruction can move data
         to or from the status register (although the user can only access the low byte using
        MOVE. B), and the user stack pointer can be set while in the system state using a special
        MOVE. An EXG instruction permits exchanging the bits in the data or address registers.
        The instruction MOVEM, for move multiple, is a generalized PSHX or PULX instruction.
        Registers to be pushed or pulled are specified by separators "/," meaning AND, and " --,"
        meaning TO, The instruction MOVEM DO/D1/AO, - (A7 ) pushes DO, Dl, and AO
        onto the user's stack (or system stack if in the system mode). However, any address
        register may be used in lieu of A7, so that the user may create many stacks or queues and
        use this instruction with them. MOVEA is a variation of MOVE that moves to an address
        register and that does not affect the condition codes, MOVEQ is a short version of MOVE
         immediate using an 8-bit signed immediate operand, and MOVEP is a MOVE that can be
         used to move data to an 8-bit I/O device that might be designed for the 6812.
            Other instructions from the move class include the LEA instruction, which works
        just like LEAX in the 6812; PEA, which pushes this effective address on the stack; and
        the familiar TST and CLR instructions. The LINK and UNLINK instructions are designed
        to simplify allocation and deallocation of local variables using the stack marker, as
        discussed in Chapter 6. The instruction LINK AO will push AO onto the stack, put the
        resulting stack address into AO, and add (negative 10) to the stack pointer to allocate ten
         bytes. The instruction UNLINK AO deallocates by reversing this procedure, copying
        AO into the stack pointer and then pulling AO from the stack.
            Arithmetic instructions are again similar to 6812 arithmetic instructions. As with
        MOVE instructions, ADD, SUB, and CMP have byte, word, and long forms, and ADDA and
         SUBA are similar to MOVEA. A memory-to-memory compare CMPM uses preincrement
        addressing to permit efficient comparison of strings. There are no INC or DEC
         instructions. Rather ADDQ can add 1 to 8, and SUBQ can subtract 1 to 8, from any
        register. These instructions are generalized INC and DEC instructions. Multiple-precision
        arithmetic uses ADDX, SUBX, and NEGX in the same way that ADC is used in the 6812,
        except that the Z bit is not set, only cleared if the result is nonzero and only
        predecrement addressing is used. The handling of Z facilitates multiple-precision tests for
        a zero number. Decimal arithmetic uses ABCD, SBCD, and NBCD and is designed to work
        like multiple-precision binary arithmetic such as ADDX. However, only bytes cart be
        operated on in these instructions. A special compare instruction CHK is used to check
        addresses. For example, CHK DO, #$ 1000 will allow the program to continue if DO is
        between 0 and 1000; otherwise, it will jump to an error routine much as the SWI
        instruction does in the 6812. Finally, this machine has multiply and divide instructions
        for signed and unsigned 16-bit operands that produce 32-bit results. Logic instructions are
        again very familiar. We have AND, OR, and EOR as in the 6812. As with ADD, the
         instructions AND and OR can operate on a data register and memory word, putting the
        result in the memory word. We have BCLR, BSET, and BTST as in the 6805 and also a
   382   383   384   385   386   387   388   389   390   391   392