60 likes | 183 Views
Computer Architecture EKT 422. Chapter 10 Instruction Sets: Characteristics and Functions (cont.). Stacks. Is an ordered set of elements. Accessed once at a time Point of access call top of the stack. Last element in stack call base of the stack. Last-in-first-out (LIFO).
E N D
Computer Architecture EKT 422 Chapter 10 Instruction Sets: Characteristics and Functions (cont.)
Stacks • Is an ordered set of elements. • Accessed once at a time • Point of access call top of the stack. • Last element in stack call base of the stack. • Last-in-first-out (LIFO)
Stack-oriented Operation • PUSH • Append a new element on top of the stack • POP • Delete the top element of the stack • Unary operation • Perform operation on top of the stack and replace top element with the result • Binary operation • Perform operation on top two element of the stack. It will delete top two element of the stack and replace it with the result of operation
Basic stack operation SP I SP SP J J J SP K J X K K K L L L L M M M M . . . . . . . . . . . . . . . . AFTER MULTIPLICATION OPERATION INITIAL STATE AFTER PUSH AFTER POP
Exercise 1 • Writing a program to compute equation below using zero-address machine. X= (A + B x C) / ((D + E) x F) Draw the diagram to describe the stack process
Answer 1 PUSH A PUSH B PUSH C MUL ADD PUSH D PUSH E ADD PUSH F MUL DIV POP X