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

134                   Chapter 5 Advanced Assemblers, Linkers, and Downloaded


        9 . A program is to have symbolic names A4, B32, and MACHINE. Write the EQU
        directives to set A4 to 1, B32 to 2, and MACHINE to B32. Write a program segment
        that will store accumulator A to location $0 if MACHINE is B32 but will store
        accumulator A into location $1 if MACHINE is A4. Comment on the use of conditional
        expressions to handle programs that will be assembled to ran in different environments.
        10. A program is to have symbolic names LITE, FULL, and FEATURES. Write the
        EQU directives to set LITE to 1, B32 to 2, and FEATURES to FULL. Write a program
        segment that will execute a subroutine SUB if FEATURES is FULL. Comment on the
        use of conditional expressions to handle programs that will be assembled for different
        levels of features for different-priced markets.

        11. A program is to have symbolic names TRUE, FALSE, and DEBUG. Write the
        EQU directives to set TRUE to 1, FALSE to 0, and DEBUG to TRUE. Write a program
        segment that will execute the 6812 background instruction if DEBUG is TRUE.
        Comment on the use of conditional expressions in debugging.

        12. Write a shortest macro BITCOUNT that computes the number of bits equal to 1 in
        accumulator D, putting the number in accumulator B.
        1 3. Write shortest macros for the following nonexistent 6812 instructions:

             (a)NEGD        (b)ADX              (c)INCD          (d) ASRD
        14. Write a shortest macro NEGT that replaces the number stored at location A with its
        two's complement whose size is indicated by the size parameter appended to the macro
        name NEGT. This macro should change no registers. The call's form should be NEGT.B
        A, NEGT.W A, or NEGT.L A. Why can't NEG be the name of this macro?

        15. Write a shortest macro INCR that increments the number stored at the address
        given as the macro's parameter A, whose size is indicated by the size parameter appended
        to the macro name INCR. The call's form should be INCR.B A, INCR.W A, or INCR.L
        A. No registers should be changed by the macro. Use the macro invocation counter rather
        than the location counter "*." Why can't we use the name INC for this macro?
        16. Write a shortest macro MOVE, as in §5.4, so that no registers are changed except
        the CC register, which should be changed exactly like a load instruction.
        17. Write a shortest macro XCHG that will exchange N bytes between locations L and
        M. No registers should be changed by the macro. The call should be of the form XCHG
        LJVLN. If N is missing, assume it is 2. A typical use would be

                                       XCHG      L,M,N
        1 8. Write a shortest macro for each of CLEAR, SET, and TEST, that will clear, set,
        and test the ith bit in the byte at location L. (Bits are labeled right to left in each byte
        beginning with 0 on the right.) For example, CLEAR L,5 will clear bit #5 in location
        L.
   152   153   154   155   156   157   158   159   160   161   162