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

54                                            Chapter 2 The Instruction Set


             (a) Accumulator A is an upper- or lower-case character. Convert it to lower case,
             (b) Accumulator A is an upper- or lower-case character. Convert it to upper case.
             (c) Accumulator A is a single BCD number. Convert it to an ASCII character.
             (d) Accumulator A is an ASCII character. Convert it to a BCD number.

         11. Write a fastest program segment to put the following property, of a number in
        Accumulator A, into accumulator B (do not use branch instructions). For part (c),
        assume that location $822 is a scratch byte.
           (a) the count of the number of 1. 's (b) the parity (c) the number of leading zeros

         12. A 32-bit number is in accumulator D (low-order) and index register Y (high-order).
        Write a shortest program segment to execute the following on these same registers.
           (a) logical shift left 1 bit (b) logical shift right 1 bit (c) arithmetic shift right 1 bit

        13. Illustrate the differences between BLT and BMI with an example that branches to
        location L if accumulator A is less than the contents of the byte at $869.
        14. Will a signed branch work after a DEC or INC instruction? Explain. What about
        unsigned branches?

        15. Assume the following instruction is missing from the 6812 instruction set. Show
        the shortest program segment that will accomplish the same effect as the missing
         instruction, except that the condition codes will be changed.
              (a) BRCLR $811,#$f,L (b) BRSET $810,#$aa,L (c) DBNE A,L
         16. The 6812 doesn't have an LBSR instruction. Compare the static efficiency of JSR,
        using program counter relative addressing, to an LBSR, which will be coded like LBRA.
        17. Figure 2.16 shows a delay loop for up to about 25 msec. Write a shortest delay
        loop for up to 27 minutes. You do not need to compute two constants used in this loop.
        18. Assume the following instruction is missing from the 6812 instruction set. Show
        the shortest program segment that will accomplish the same effect as the missing
        instruction, except that the condition codes will be changed differently. For part (c),
        assume that index registers X and Y can be modified.

              (a) MINM 0,X             (b)EMAXD 0,Y              (c) EMACS $810
        19. Write a shortest program to execute an inner product using EMACS and EMULS.
        Let x[0] be at $810, x[l] be at $812, y[0] be at $814, y[l] be at $816; the program is to
        put x[0] y[0] + x[l] y[l] into $81a, and $818 and $819 are scratch bytes. All numbers
        are 16-bit signed numbers.

        20. Write a shortest program segment to extract the three bits that were inserted by
        Figure 2.20, leaving the extracted bits right-justified in accumulator B.
        21. Write a shortest program segment to convert temperature from Fahrenheit (±300°),
        in Accumulator D, to Celsius. The output value is left in Accumulator D. You may
        preload constants into registers to shorten your machine code, but show their values.
   72   73   74   75   76   77   78   79   80   81   82