Page 76 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 76
PROBLEM'S 53
PROBLEMS
When a program (ending in BGND or SWI) or program segment is asked for in the
problems below, use the format that is used for the examples in the text.
1 . Assume the following instruction is missing from the 6812 instruction set. Show
the shortest program segment that will accomplish exactly the same effect as this
missing instruction. That is, this program segment must give the same results in all the
registers, including the condition code register.
(a)XGDX(or EXG X,D) (b) TFR X,Y (c) PSHD
2 . Assume MOVE is missing from the 6812 instruction set. Show the shortest
program segment that accomplishes exactly the same effect as MOVE $803 / $822.
3 . Show the shortest program segment that will push the following 32-bit constant
on the stack. The most significant byte must be at the lowest address.
(a)0 (b)l (c)-l
4 . Write a shortest program to evaluate a quadratic polynomial. Let a be at $810, b be
2
at $812, c be at $814, x be at $816; the program is to put a x + b x + c into $818. All
numbers, including the result, are 16-bit two's-complement signed numbers.
5 , Write a shortest program to execute an inner product. 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] + xfl] yfl]
into $818. All numbers are 16-bit unsigned numbers.
6 . Write a shortest program to compute the resistance of a pair of resistors connected
in parallel. Let rl be at $810 and r2 be at $812; the program is to put rl II r2 into $814.
All values are 16-bit unsigned numbers.
7 . If a count C is obtained, the frequency is 8,000,000 / C. Write a shortest program
to compute the 16-bit frequency corresponding to the 16-bit count C in location $8la,
putting the result into $81c. Show this program, beginning at $81e, in hexadecimal.
8 . Why doesn't DAA work after an INC, DEC, or ASR instruction?
9 . Assume the following instruction is missing from the 6812 instruction set. Show
the shortest program segment that will accomplish exactly the same effect as the
missing instruction. For part (c) assume that locations $813 and $814 are able to be used
as scratch bytes. (Scratch means the location is available for storing temporary results.)
(a)BSET $810,#$aa (b) BCLR $811,#$f (c) EORA $812
1 0, ASCII characters are defined by Table 4.1. Write a single instruction for the following: