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

2,4 Edit Instructions                                                41
















                                Figure 2.13. Shift Hardware
        2.4 Edit Instructions

        Edit instructions (see Table 2.7) rearrange bits of data without generating new bits as an
        ADD does. Large machines have complex edit instructions, but microcomputers have
        simple ones. For example, the arithmetic shift-left instructions shift all the bits left,
        putting the most significant bit into the carry bit of the condition code register and
        putting a zero in on the right (the same as LSLA) (see Figure 2.12a). This, except for
        overflow, doubles the unsigned or signed number contained in A, The ASR instruction
        keeps the sign bit unchanged and shifts all other bits to the right, putting the least
        significant bit into the carry bit (see Figure 2.12c). As mentioned in the discussion of
        the arithmetic class of instructions, ASR divides the original two's-complement number
        contained in an accumulator or memory location by two (rounding down).
            The shift operation is generally done in the MPU, and is shown in Figure 2.13 for
        LSRA. The MPU shifts the data because these data paths follow the same data paths as
        addition and logical operations (see Figures 1.4d and 2.11 a). Each flip-flop's output feeds
        through the multiplexer in the MPU to the input of the next bit to the right; a zero is fed
        into the leftmost flip-flop and the rightmost flip-flop's output is put in the carry C.

























                        Figure 2.14. Program Segment to Swap Nibbles
   59   60   61   62   63   64   65   66   67   68   69