SlideShare a Scribd company logo
Central Processing Unit (CPU) It is the part of the computer that performs bulk of data-processing operation. It is made up of 3 major parts as shown below :  KAPIL P.C.T.E. Control Register Arithmetic  Logic Unit  (ALU)
Components of the CPU The Register set stores intermediate date used during the execution of the instructions. The Arithmetic Logic Unit (ALU) performs the required micro-operations for executing the instructions. The Control Unit supervises the transfer of information among  the registers and instructs the ALU as to which operation to perform.  KAPIL P.C.T.E.
Stack Organization A stack is a storage device for storing information in such a manner that the element stored last is the first to be retrieved (LIFO –Last-in, First-out). The stack is a memory unit with an address register called a  stack pointer  (SP), which always points at the top element in the stack. The two operations of a stack are the insertion (PUSH) and deletion (POP) of elements. PUSH-operation increments the SP. POP-operation decrements the SP. KAPIL P.C.T.E.
Stack Organization (contd) Stack can reside in a portion of a large memory unit or it can be organized as a collection of a finite number of (fast) registers. Fig here shows an organization of 64-word register stack. KAPIL P.C.T.E.
Operations on Stack PUSH (performed if stack is not full  i.e.  if FULL = 0): KAPIL P.C.T.E.
Operations on Stack POP (performed if stack is not empty  i.e.  if EMTY = 0): KAPIL P.C.T.E.
Stack implemented in the Computer Memory Stack can also be implemented with RAM attached to a CPU: a portion of memory is assigned to a stack operation a special register is used as a stack pointer (SP). Fig. next shows how a portion of memory partitioned into three  segments : Program, Data and Stack. KAPIL P.C.T.E.
KAPIL P.C.T.E.
Utility of using Stack(Evaluating Arithmetic Expressions) A stack is effective for evaluating  A rithmetic expressions . Arithmetic operations are usually written in  I nfix Notation :  each operator resides   between   the operands ,  (A * B) + (C * D)  where * denotes multiplication: A * B and C * D has to be computed and stored. after the two products, sum (A * B) + (C * D) is computed there is no straight forward way to determine the next operation that is performed. KAPIL P.C.T.E.
Continued Arithmetic expressions can be represented  in Prefix Notation  (also referred to as Polish Notation) :  operators are placed before the operands . The  Postfix Notation (Reverse Polish Notation (RPN)  ) places the operator after the operand. E. g  .: A + B --- Infix notation +AB ---- Prefix notation (PN) AB+ ---- Postfix notation (RPN) KAPIL P.C.T.E.
Continued E. g. the expression A * B + C * D is written in  RPN as AB* CD*+ and is evaluated by scanning from left to right: when operator is found, the operation is performed by using operands on the left side of the operator. The operator and operands are replaced by the result of operation. The scan is continued and the procedure is repeated for every operator. KAPIL P.C.T.E.
1.  *  is found 2.  Take the two operands from left:  A and B 3.  Compute  P = A * B 4.  Replace operands and operator with the result =>  PCD*+ 5.  continue scan 6.  *  is found 7.  Take the two operands from left:  C and D 8.  Compute  Q = C * D 9.  Replace operands and operator with the result =>  PQ+ 10. continue scan 11.  +  is found 12. Take the two operands from left:  P and Q 13. Compute  R = P + Q 14. Replace operands and operator with the result: R 15. continue scan: no more operators => stop; R is the result of evaluation. KAPIL P.C.T.E.
Conversion of Expressions from Infix to RPN The conversion from infix to RPN must take into consideration the operational hierarchy of infix notation: 1. First perform Arithmetic operation inside inner parentheses. 2.  Then perform Arithmetic operation inside outer parentheses. 3.  P erform multiplication and division before addition and subtraction. KAPIL P.C.T.E.
Example---(A + B)*[ C*( D + E) + F] becomes AB+ DE+ C* F+* which is computed: 1.  P = A+ B => PDE+ C* F+* 2.  Q = D+ E => PQC* F+* 3.  R = Q * C => PRF+* 4.  S = R+ F => PS* 5.  T = P* S T represents the result: T = AB+ DE+ C* F+*
Continued RPN is the most efficient method known for evaluating arithmetic expressions. Used in electronic calculators. Stack is useful for evaluating arithmetic expressions in RPN operands are pushed into the stack in the order of appearance (in RPN) the topmost operands are popped from the stack and used for the operation The result is pushed to replace the popped operands Most compilers convert all arithmetic expressions into Polish notation: efficient translation of arithmetic expressions into machine language instructions. KAPIL P.C.T.E.
Example (3* 4)+( 5* 6) => 34* 56*+ KAPIL P.C.T.E.

More Related Content

PPTX
Data transfer and manipulation
PDF
C - Programming Assignment 1 and 2
DOCX
JS2 COMPUTER STUDIES FIRST TERM C.A 2
DOCX
SS2 Data Processing Examination with Test of Practicals (Third Term)
PPT
Different type of buses
PDF
Unit 4-input-output organization
DOCX
Encapsulation in C++
DOCX
S2 DATA PROCESSING FIRST TERM C.A 2
Data transfer and manipulation
C - Programming Assignment 1 and 2
JS2 COMPUTER STUDIES FIRST TERM C.A 2
SS2 Data Processing Examination with Test of Practicals (Third Term)
Different type of buses
Unit 4-input-output organization
Encapsulation in C++
S2 DATA PROCESSING FIRST TERM C.A 2

What's hot (20)

PPT
Virtual memory
PDF
Debug tutorial
PPTX
pipeline in computer architecture design
PPTX
INSTRUCTION LEVEL PARALLALISM
PPTX
Data Hazard and Solution for Data Hazard
PDF
Constructors destructors
DOCX
S3 DATA PROCESSING FIRST TERM PRE-WAEC (2ND HALF EXAMINATION)
PPTX
Preprocessor directives in c laguage
PPT
Cache memory presentation
PPTX
Bootstrap loader
PDF
ITI Training Officer COPA Previous Year Paper MCQ
DOCX
Computer architecture mcq (2)
PPTX
Hardwired control
DOC
module 1 computer architecture diploma
PPTX
Chapter 04 object oriented programming
PPTX
C++ programming function
PPTX
User defined functions
PPTX
OOP Unit 2 - Classes and Object
DOCX
Technical questions
PPT
Preprocessors
Virtual memory
Debug tutorial
pipeline in computer architecture design
INSTRUCTION LEVEL PARALLALISM
Data Hazard and Solution for Data Hazard
Constructors destructors
S3 DATA PROCESSING FIRST TERM PRE-WAEC (2ND HALF EXAMINATION)
Preprocessor directives in c laguage
Cache memory presentation
Bootstrap loader
ITI Training Officer COPA Previous Year Paper MCQ
Computer architecture mcq (2)
Hardwired control
module 1 computer architecture diploma
Chapter 04 object oriented programming
C++ programming function
User defined functions
OOP Unit 2 - Classes and Object
Technical questions
Preprocessors
Ad

Viewers also liked (20)

PPTX
Lecture 23
PPTX
Register organization, stack
PPTX
Basic Processing Unit
PPT
Instruction format
PPS
Computer instructions
PPT
Addressing modes
PPS
Interrupts
PPTX
Cloud computing
PPT
CO by Rakesh Roshan
PPT
Central Processing Unit User View
PPT
STACK
PPT
Unit 3 basic processing unit
PPTX
Register Organization and Instruction cycle
PPT
Computer Organization and Assembly Language
PDF
Lecture 2
PPT
Addressing modes (detailed data path)
PPTX
Buses in a computer
PDF
Logic microoperations
PPTX
Class 7 science project
PPTX
Logical and shift micro operations
Lecture 23
Register organization, stack
Basic Processing Unit
Instruction format
Computer instructions
Addressing modes
Interrupts
Cloud computing
CO by Rakesh Roshan
Central Processing Unit User View
STACK
Unit 3 basic processing unit
Register Organization and Instruction cycle
Computer Organization and Assembly Language
Lecture 2
Addressing modes (detailed data path)
Buses in a computer
Logic microoperations
Class 7 science project
Logical and shift micro operations
Ad

Similar to Csa stack (20)

PDF
Data structure and algorithm.(dsa)
PPTX
5.stack
PPTX
Stack_Overview_Implementation_WithVode.pptx
PPTX
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
PPTX
Lecture 6 data structures and algorithms
PPTX
Stack data structure
PDF
Central processing unit
DOCX
Computer Organization and 8085 microprocessor notes
PPTX
Stack Data Structure
PPT
Stack in Data Structure
PPTX
Lec 06 Applications of Stacks.pptx Applications of Stack
PPT
PPTX
Application of Stack - Yadraj Meena
PPTX
Applicationofstack by Ali F.RAshid
PDF
Data Structures And Algorithms(stacks queues)
PDF
Stack unit-ii
PPTX
Lec5-Stack-bukc-28022024-112316am (1) .pptx
PPTX
Unit 3 Stacks and Queues.pptx
PPTX
Prefix, Infix and Post-fix Notations
PPTX
Introduction To Stack
Data structure and algorithm.(dsa)
5.stack
Stack_Overview_Implementation_WithVode.pptx
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Lecture 6 data structures and algorithms
Stack data structure
Central processing unit
Computer Organization and 8085 microprocessor notes
Stack Data Structure
Stack in Data Structure
Lec 06 Applications of Stacks.pptx Applications of Stack
Application of Stack - Yadraj Meena
Applicationofstack by Ali F.RAshid
Data Structures And Algorithms(stacks queues)
Stack unit-ii
Lec5-Stack-bukc-28022024-112316am (1) .pptx
Unit 3 Stacks and Queues.pptx
Prefix, Infix and Post-fix Notations
Introduction To Stack

Csa stack

  • 1. Central Processing Unit (CPU) It is the part of the computer that performs bulk of data-processing operation. It is made up of 3 major parts as shown below : KAPIL P.C.T.E. Control Register Arithmetic Logic Unit (ALU)
  • 2. Components of the CPU The Register set stores intermediate date used during the execution of the instructions. The Arithmetic Logic Unit (ALU) performs the required micro-operations for executing the instructions. The Control Unit supervises the transfer of information among the registers and instructs the ALU as to which operation to perform. KAPIL P.C.T.E.
  • 3. Stack Organization A stack is a storage device for storing information in such a manner that the element stored last is the first to be retrieved (LIFO –Last-in, First-out). The stack is a memory unit with an address register called a stack pointer (SP), which always points at the top element in the stack. The two operations of a stack are the insertion (PUSH) and deletion (POP) of elements. PUSH-operation increments the SP. POP-operation decrements the SP. KAPIL P.C.T.E.
  • 4. Stack Organization (contd) Stack can reside in a portion of a large memory unit or it can be organized as a collection of a finite number of (fast) registers. Fig here shows an organization of 64-word register stack. KAPIL P.C.T.E.
  • 5. Operations on Stack PUSH (performed if stack is not full i.e. if FULL = 0): KAPIL P.C.T.E.
  • 6. Operations on Stack POP (performed if stack is not empty i.e. if EMTY = 0): KAPIL P.C.T.E.
  • 7. Stack implemented in the Computer Memory Stack can also be implemented with RAM attached to a CPU: a portion of memory is assigned to a stack operation a special register is used as a stack pointer (SP). Fig. next shows how a portion of memory partitioned into three segments : Program, Data and Stack. KAPIL P.C.T.E.
  • 9. Utility of using Stack(Evaluating Arithmetic Expressions) A stack is effective for evaluating A rithmetic expressions . Arithmetic operations are usually written in I nfix Notation : each operator resides between the operands , (A * B) + (C * D) where * denotes multiplication: A * B and C * D has to be computed and stored. after the two products, sum (A * B) + (C * D) is computed there is no straight forward way to determine the next operation that is performed. KAPIL P.C.T.E.
  • 10. Continued Arithmetic expressions can be represented in Prefix Notation (also referred to as Polish Notation) : operators are placed before the operands . The Postfix Notation (Reverse Polish Notation (RPN) ) places the operator after the operand. E. g .: A + B --- Infix notation +AB ---- Prefix notation (PN) AB+ ---- Postfix notation (RPN) KAPIL P.C.T.E.
  • 11. Continued E. g. the expression A * B + C * D is written in RPN as AB* CD*+ and is evaluated by scanning from left to right: when operator is found, the operation is performed by using operands on the left side of the operator. The operator and operands are replaced by the result of operation. The scan is continued and the procedure is repeated for every operator. KAPIL P.C.T.E.
  • 12. 1. * is found 2. Take the two operands from left: A and B 3. Compute P = A * B 4. Replace operands and operator with the result => PCD*+ 5. continue scan 6. * is found 7. Take the two operands from left: C and D 8. Compute Q = C * D 9. Replace operands and operator with the result => PQ+ 10. continue scan 11. + is found 12. Take the two operands from left: P and Q 13. Compute R = P + Q 14. Replace operands and operator with the result: R 15. continue scan: no more operators => stop; R is the result of evaluation. KAPIL P.C.T.E.
  • 13. Conversion of Expressions from Infix to RPN The conversion from infix to RPN must take into consideration the operational hierarchy of infix notation: 1. First perform Arithmetic operation inside inner parentheses. 2. Then perform Arithmetic operation inside outer parentheses. 3. P erform multiplication and division before addition and subtraction. KAPIL P.C.T.E.
  • 14. Example---(A + B)*[ C*( D + E) + F] becomes AB+ DE+ C* F+* which is computed: 1. P = A+ B => PDE+ C* F+* 2. Q = D+ E => PQC* F+* 3. R = Q * C => PRF+* 4. S = R+ F => PS* 5. T = P* S T represents the result: T = AB+ DE+ C* F+*
  • 15. Continued RPN is the most efficient method known for evaluating arithmetic expressions. Used in electronic calculators. Stack is useful for evaluating arithmetic expressions in RPN operands are pushed into the stack in the order of appearance (in RPN) the topmost operands are popped from the stack and used for the operation The result is pushed to replace the popped operands Most compilers convert all arithmetic expressions into Polish notation: efficient translation of arithmetic expressions into machine language instructions. KAPIL P.C.T.E.
  • 16. Example (3* 4)+( 5* 6) => 34* 56*+ KAPIL P.C.T.E.