August 1999
CS202 : COMPUTER ARCHITECTURE AND DATA COMMUNICATIONS

QUESTION 5

Total Marks: 20 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 5

(a) What is a subroutine? Why are subroutines useful?

 

[3]
(b) Explain in detail the what is meant by the term parameter passing in the context of subroutines.

 

[4]
(c) Because of the nature of subroutines or nested subroutines the addresses can be stored onto a memory stack. Explain the operation of stacks. (Your answer should include the PUSH and POP operations and the role of the Stack Limit, Stack Pointer and the Stack Base).

 

[7]
(d) If an opcode mnemonic such as SUB, ADD, MUL, and DIV pops the top two numbers from the stack, performs the appropriate operation in the ALU then pushes the result back onto the stack, write down the expression which is calculated by the following sequence of instructions and give the value of X :

PUSH 2
PUSH 4
PUSH 5
ADD
PUSH 2
MUL
ADD
POP X

Show your working by drawing a diagram showing the state of the stack after each operation, and therefore state the minimum stack size needed to perform this calculation.

 

[4]
(e) There are a number of different ways to implement a stack, using main memory and/or register storage. Which method would be most appropriate for the calculation above, and why?

 

[2]