Date: Tue, 14 Jan 1997 23:19:27 GMT Server: NCSA/1.5 Content-type: text/html
Problem 1: [9 points]
Translate the following recursive Pascal function into a
recursive MC68000 subroutine.
As you already know, this function computes for any
integer
and any positive integer
.
Then calculate the size of the stack frame for each call (you need not use the link and unlk instructions.) Suppose you were running your program on a machine with stack size bounded above by 16K. What is the maximum value of n for which your program would be able to calculate power(m,n)?
Problem 2: [8 points]
Suppose that the above subroutine is called from the main program with two addresses (each 32-bits), say ad1 and ad2, passed as parameters via the run-time stack.
Problem 3: [8 points]
Given above is a recursive subroutine called strange. Two parameters, a 16-bit non-negative integer, say N, and a 32-bit address, say A, are passed to the subroutine via the run-time stack. As you might notice, the subroutine strange returns a 16-bit answer in (D0.W).
list: dc.w 1, 2, 3, 4
Further suppose that the number 4 is passed in as N and the address list is passed in as A to the subroutine strange. What is the answer returned by strange in (D0.W)?
list: dc.w 1, 2, 3, 4, 5
If the number 5 and the address list are passed into strange, then will strange return an answer in (D0.W)? If so, what is it? If not, why not?