December
1998 QUESTION 3 Total Marks: 20 Marks |
Click here to access other
questions
Click to access
|
| (a) | Define the following terms: | [6] |
| (i) stack pointer; | ||
| (ii) stack limit; | ||
| (iii) stack overflow
|
||
| (b) | A subroutine call operation begins as: | [4] |
| SP <-- SP + 1 (increment stack pointer) | ||
| Mem[SP] <-- PC (pushes content to PC onto the stack) | ||
| PC <-- Starting
address of subroutine (transfer control to subprogram)
|
||
| Show, in similar terms, what
operations take place when control returns from the subroutine to the main calling
program.
|
||
| (c) | State two difference between a
subroutine and an interrupt.
|
[4] |
| (d) | Stacks are often used to evaluate
logical and arithmetic expressions. Given a stack in a O-Address format, write a program
to evaluate the following expression: X := ((A * B / C) + (D + C - F)) / (G - H) What maximum stack size (stack depth) is needed in order to execute your program? Explain your answer. |
[6] |