April
1999 QUESTION 2 Total Marks: 20 Marks |
Click here to access other
questions
GRADE A
|
(a) | In stack operations, what is a binary operation? | [2] |
Addition of top two
elements of stack.
|
||
(b) | Describe the steps involved in using a specific linkage register for passing parameters (at low-level) into a subroutine. Assume [R2] is the specific linkage register. | [6] |
|
||
(c) | The use of nested subroutines means that a
subroutine can call another subroutine to perform some task. Given the diagram shown on the following page, for each of the following give the location of the Stack Pointers (SP) and the Program Counter (PC), and, for each subroutine call, give the starting address loaded into the PC when the subroutine call is executed. Assume that the only data stored on the stack is the PC.
|
[12] |
(i) before calling SUB1, | ||
(ii) when SUB1 is called, | ||
(iii) before calling SUB2, | ||
(iv) when SUB2 is called, | ||
(v) before calling SUB3, | ||
(vi) when SUB3 is called, | ||
(vii) upon returning from SUB3, | ||
(viii) upon returning from SUB2, and | ||
(ix) upon returning from SUB1. | ||
![]() |
||
(i) Before calling
SUB1 PC = 3000 SP = C010 (ii) When
SUB1 is called (iii) Before calling SUB2 (iv) When SUB2 is loaded (v) Before calling SUB3 (vi) When SUB3 is called (vii) Upon returning from SUB3 (viii) Upon returning from SUB2 (ix) Upon returning from SUB1 |