Page 402 - Introduction to Microcontrollers Architecture, Programming, and Interfacing of The Motorola 68HC12
P. 402
PROBLEMS 379
18. Write a fastest 68300 series subroutine MULT that multiplies two 32-bit unsigned
binary numbers in DO and Dl, to produce a 64-bit product in DO:D1.
19. Write a position-independent, reentrant, fastest 68300 series subroutine DOTPRD
that passes parameters on the stack, in the same manner as that subroutine in Figure
6.21.
2 0. Write a position-independent reentrant 68300 series subroutine QUAD that evaluates
2
the quadratic function ax + bx + c, where signed 16-bit arguments a, b, c, and x are
passed on the stack from low to high addresses respectively, named PARA, PARB, PARC,
and PARX, and the output is returned in register DO. In order to demonstrate local
2
variables, as part of your subroutine, store ax in a 16-bit local variable on the stack.
Write a calling sequence that writes 1, 2, 3, and 4 into PARA, PARE, PARC, and PARX,
calls QUAD, and moves the result to global variable ANSWER.
21. Write a shortest position-independent reentrant 68300 series subroutine PAR that
computes the parallel resistance of two resistors Rl and R2, where unsigned 16-bit
arguments are passed on the stack and named Rl and R2, and the output is returned in
register DO. In order to demonstrate local variables, as part of your subroutine, store Rl
times R2 in a 16-bit local variable on the stack. Write a calling sequence that writes 100
into Rl and R2, calls PAR, and moves the result to global variable ANSWER.
2 2. Write a fastest position-independent, reentrant, 68300 series subroutine CAH that
converts a string of ASCII characters representing a hexadecimal number to an unsigned
binary number in DO. The first character is pointed to by AO, and the length is in DO.
2 3. Write a position-independent reentrant 500 series subroutine QUAD that evaluates
2
the quadratic function ax + bx + c, where signed 16-bit arguments a, b, c, and x are
passed in registers r27, r28, r29, and r30, respectively, and the output is returned in
register r31. In order to demonstrate local variables, as part of your subroutine, store ax 2
in register r26. Write a calling sequence that writes 1, 2, 3, and 4 into the four registers
holding a through x, resepectively, and moves the result to global variable ANSWER.
2 4. Write a shortest position-independent reentrant 500 series subroutine PAR that
computes the parallel resistance of two resistors Rl and R2, where unsigned 16-bit
arguments are passed in registers r29 and r30, and the output is returned in register r31.
In order to demonstrate local variables, as part of your subroutine, store Rl times R2 in
a 16-bit local variable in register r28. Write a calling sequence that writes 100 into Rl
and R2, calls PAR, and moves the result to global variable ANSWER.
2 5. Select the most suitable microprocessor or microcomputer among the 6805, 6811,
6812, or for the following applications.
(a) A graphics terminal needing 250K bytes of programs and 100K bytes of data
(b) A motor controller, storing a 15K program, needing to quickly evaluate polynomials
(c) A text editor for a "smart terminal" needing 8K for programs and 40K for data storage
(d) A keyless entry system (combination lock for a door) requiring $DO bytes of program
memory and 2 parallel I/O ports.

