Explain the following with the help of a suitable diagram or an example.
Evaluation stack architecture 5m Dec2005
A stack is a data structure that implements Last-In-First-Out (LIFO) access policy. You could add an entry of data (or value) to the stack with a PUSH (value) Function and remove an entry of data (or value) from the stack with a POP ( ) Function.
No explicit operands are used in ALU instructions, but one operand in PUSH (value) as parameter to be pushed on to the stack and In POP ( ) as return value to be popped from the stack.
Examples of such computers are Burroughs B5500/6500, HP 3000/70 etc.
On a stack machine “C = A + B” might be implemented as:
PUSH A PUSH B ADD // operator POP operand and PUSH result (implicit on top of stack) POP C
Stack Architecture: Pros and Cons
- Small instructions (does not need many bits to specify the operation).
- Compiler is easy to write.
- Lots of memory accesses required – everything that is not on the stack is in memory.
Thus, the result of which the machine performance is poor.