Chapter 04: Instruction Sets and the Processor organizations. Lesson 18: Stack-based processor Organisation

Similar documents
Chapter 04: Instruction Sets and the Processor organizations. Lesson 08: Processor Instructions - Part 1

Computer Architecture Lecture No.4 5-Instruction Set Architecture and Design 5-1 Memory locations and Operations. word

COMPUTER ORGANIZATION & ARCHITECTURE

STACKS. A stack is defined in terms of its behavior. The common operations associated with a stack are as follows:

CDA 3103 Computer Organization Homework #7 Solution Set

Abstract Data Types. Stack. January 26, 2018 Cinda Heeren / Geoffrey Tien 1

The Assembly Language of the Boz 5

CSCI 402: Computer Architectures. Instructions: Language of the Computer (4) Fengguang Song Department of Computer & Information Science IUPUI

CHAPTER 5 A Closer Look at Instruction Set Architectures

Problem with Scanning an Infix Expression

Stack Abstract Data Type

COMPUTER ARCHITECTURE AND PARALEL PROCESSING STUDY NOTES

CS 206 Introduction to Computer Science II

10-1 C D Pearson Education, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

COSC 6385 Computer Architecture. Instruction Set Architectures

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

Instruction content (2/2) Instruction content (1/2) The Instruction Set. Chapter 9. Each instruction must contain 4 basic pieces of information

Formal Languages and Automata Theory, SS Project (due Week 14)

Stack Applications. Lecture 27 Sections Robb T. Koether. Hampden-Sydney College. Wed, Mar 29, 2017

09 STACK APPLICATION DATA STRUCTURES AND ALGORITHMS REVERSE POLISH NOTATION

Prefix/Infix/Postfix Notation

Instructions: Language of the Computer

Chapter 5. A Closer Look at Instruction Set Architectures

The von Neumann Architecture. IT 3123 Hardware and Software Concepts. The Instruction Cycle. Registers. LMC Executes a Store.

COMPUTER HARDWARE. Instruction Set Architecture

CS 206 Introduction to Computer Science II

Review Questions. 1 The DRAM problem [5 points] Suggest a solution. 2 Big versus Little Endian Addressing [5 points]

The Stack and Queue Types

Problem with Scanning an Infix Expression

ECE 372 Microcontroller Design Assembly Programming. ECE 372 Microcontroller Design Assembly Programming

Word Bank - questions 1-6. Place the letter of the matching term in the space provided. (2 pts. each)

Chapter 2A Instructions: Language of the Computer

CHAPTER 8: Central Processing Unit (CPU)

The x87 Floating-Point Unit

Computer Organization MIPS ISA

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

STACKS AND QUEUES. Problem Solving with Computers-II

Chapter 5. A Closer Look at Instruction Set Architectures

Understand the factors involved in instruction set

TABLE 9-1. Symbolic Convention for Addressing Modes. Register indirect LDA (R1) ACC M[ R1] Refers to Figure 9-4. Addressing mode. Symbolic convention

CS 171: Introduction to Computer Science II. Stacks. Li Xiong

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

Page 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions

Topic Notes: MIPS Instruction Set Architecture

Some Applications of Stack. Spring Semester 2007 Programming and Data Structure 1

Instruction Set extensions to X86. Floating Point SIMD instructions

Instruction Sets: Characteristics and Functions

Instruction Set Architecture. "Speaking with the computer"

Assembly language Simple, regular instructions building blocks of C, Java & other languages Typically one-to-one mapping to machine language

Expectations. Why learn Assembly Language? Administrative Issues. Assignments. CSC 3210 Computer Organization and Programming

Stacks. Chapter 5. Copyright 2012 by Pearson Education, Inc. All rights reserved

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

Lesson 2. Instruction set design

Chapter 02: Computer Organization. Lesson 02: Functional units and components in a computer organization- Part 1: Processor

Computer Organization CS 206 T Lec# 2: Instruction Sets

CHAPTER 5 A Closer Look at Instruction Set Architectures

CS W3134: Data Structures in Java

CS2383 Programming Assignment 3

Reconfigurable Computing Systems ( L) Fall 2012 Tiny Register Machine (TRM)

Computer Internals ECE2036. Lecture 2. ECE2036 Computer Internals Spring / 12

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions

Chapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats

-The Hacker's Dictionary. Friedrich L. Bauer German computer scientist who proposed "stack method of expression evaluation" in 1955.

SimpleCalc. which can be entered into a TI calculator, like the one on the right, like this:

Special Section: Building Your Own Compiler

Chapter 5. A Closer Look at Instruction Set Architectures

Instruction Sets: Characteristics and Functions Addressing Modes

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1

Overview. EE 4504 Computer Organization. Much of the computer s architecture / organization is hidden from a HLL programmer

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

Infix to Postfix Conversion

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

Assembly language Simple, regular instructions building blocks of C, Java & other languages Typically one-to-one mapping to machine language

Introduction. Problem Solving on Computer. Data Structures (collection of data and relationships) Algorithms

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

(Refer Slide Time: 1:40)

TSK3000A - Generic Instructions

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

ARM Instruction Set Architecture. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

University of California, San Diego CSE 30 Computer Organization and Systems Programming Winter 2014 Midterm Dr. Diba Mirza

F453 Module 7: Programming Techniques. 7.2: Methods for defining syntax

Chapter 2: Assembly Language Fundamentals. Oregon State University School of Electrical Engineering and Computer Science.

Supplement for MIPS (Section 4.14 of the textbook)

COSC 6385 Computer Architecture. Defining Computer Architecture

Support for high-level languages

In this chapter you ll learn:

EC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

Algorithms and Data Structures

19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd

17. Instruction Sets: Characteristics and Functions

Assembly Language Manual for the STACK Computer

Chapter 11. Instruction Sets: Addressing Modes and Formats. Yonsei University

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1

Assessment of Programming Skills of First Year CS Students: Problem Set

Stack Applications. Lecture 25 Sections Robb T. Koether. Hampden-Sydney College. Mon, Mar 30, 2015

CSCI 136 Data Structures & Advanced Programming. Lecture 14 Fall 2018 Instructor: Bills

Transcription:

Chapter 04: Instruction Sets and the Processor organizations Lesson 18: Stack-based processor Organisation 1

Objective To understand stack based processor organisation Instruction set of a stack organized processor Learn Post Fix Notations for Stack based Computers Learn Difference in Instructions encoding of Stack based and GPR based 2

Stack based organisation 3

Stack-based organization 1. First, because the operands and destination of an instruction in a stack-based organization are implicit, instructions take fewer bits to encode than they do in general-purpose register organizations This reduced the amount of memory taken up by programs, which was a significant issue on early machines 4

Stack-based organization 2. Second, stack-based architectures manage registers automatically, freeing programmers from the need to decide which data should be kept in the register file 5

Stack-based organization 3. Advantage of stack-based organizations is that the instruction set does not change if the sizes of the register file changes This means that programs written for a stack-based processor can be run on future versions of the processor that have more registers, and they will see performance improvements because they are able to keep more of the stack in registers 6

Stack-based organization 4. Stack-based organizations are also very easy to compile to so easy that some compilers generate stack-based versions of a program as part of the compilation process even when compiling for a GPR processor 7

Stack-based organization In a, the register file invisible to the program Instructions read their operands from, and write their results to, a stack, and it has last-infirst-out (LIFO) data-structure Stack-based organizations use the stack in place of random access register file (GPRs) for many instructions 8

Advantages Fewer bits for the instruction as the operands and destination of an instruction are implicit Automatic management of stacked registers 9

Advantages No change in instruction set if the sizes of the stacked register file changes Easy compilation Programs take up very little memory, because it is not necessary to specify where the source and destination of the operations are located 10

Stack-based and general-purpose register organizations differ Mainly in their interfaces to their register files In stack-based organizations, data is stored on a stack in memory The processor's file may be used to implement the top portion of the stack to allow faster access to the stack 11

Processor stack in stack organised computer 12

Stack-based organization Operands Get their operands from and write their results to the stack When an instruction executes, it pops its operands off of the stack, performs the required computation, and pushes the result onto the top of the stack 13

Stack based execution of instructions 14

Speed up of Stack access by a register file invisible to programmer 15

Embedded systems Stack-based organizations are somewhat more attractive for embedded systems, in which low cost and low power consumption requirements often limit the amount of memory that can be included in a system, making code size more of concern 16

Instruction set of a Stack based organisation Processor 17

Stack Organised Instruction Set PUSH #X STACK X POP a STACK LD a STACK; STACK Address of (a) ST a STACK Address of (a) STACK; 18

Stack Organised Instruction Set ADD a STACK; b STACK; STACK a + b Integers FADD a STACK; b STACK; STACK a + b Floating Points SUB a STACK; b STACK; STACK a b Integers FSUB a STACK; b STACK; STACK a b Floating Points 19

Stack Organised Instruction Set MUL a STACK; b STACK; STACK a b Integers FMUL a STACK; b STACK; STACK a b Floating Points DIV a STACK; b STACK; STACK a b Integers FDIV a STACK; b STACK; STACK a b Floating Points 20

Stack Organised Instruction Set AND a STACK; b STACK; STACK a.and. b Binary Numbers OR a STACK; b STACK; STACK a.or. b Binary Numbers NOT a STACK; STACK NOT Binary Numbers 21

Stack Organised Instruction Set ASR a STACK; b STACK; STACK a + b arithmetic left or right (+ or ) shift by b LSH a STACK; b STACK; STACK a + b logical left or right (+ or ) shift by b BR PC STACK; BEQ a STACK; b STACK; c STACK; PC c if b = a 22

Stack Organised Instruction Set BNE a STACK; b STACK; c STACK; PC c if b a BLT a STACK; b STACK; c STACK; PC c if b < a BGT a STACK; b STACK; c STACK; PC c if b > a BLE a STACK; b STACK; c STACK; PC c if b is less or equal to a 23

Stack Organised Instruction Set BGE a STACK; b STACK; c STACK; PC c if b is greater or equal to a BGE Label rb, rc PC label assigned bits by program text/assembler if rb > or = rc 24

Encoding in Postfix Notations 25

Stack-based programs Simply sequences of instructions that get executed one after the other Given a stack-based program and an initial configuration of the stack, the result of the program can be computed by applying the first instruction in the program, determining the state of the stack and memory after the first instruction completes, and repeating with each successive instruction 26

Writing programs for stack-based processors Somewhat more difficult, because stack-based processors are better suited to postfix notation (RPN) [Reversed Polish Notation] than traditional infix notation Infix notation is the traditional way of representing mathematical expressions, in which the operation is placed between the operands 27

Postfix notation The operation is placed after the operands. For example, the infix expression 2 +3 becomes 2 3 + in postfix notation. Once an expression has been recoded in postfix notation, converting it into a stack-based program is straightforward. 28

Postfix notation Starting at the left, each constant is replaced with a PUSH operation to place the constant on the stack, and operators are replaced with the appropriate instruction to perform their operation 29

Example of a stack-based program for 2 + (7 3) Convert the expression into postfix notation Best done by iteratively converting each subexpression into postfix, so 2 + (7 3) becomes 2 + (7 3 ) and then 2 (7 3 ) + 30

Conversion of t the postfix expression into a series of instructions PUSH #2 PUSH #7 PUSH #3 MUL ADD 31

Verify the this program correctness We hand-simulate its execution Three PUSH statements Stack contains the values 3, 7, 2 (starting from the top of the stack) The MUL instruction pops the 3 and 7 off the stack Multiplies them Pushes the result (21) onto the stack 32

Verification Making the stack contents 21, 2. The ADD pops these two values off of the stack and adds them, Places the result (23) onto the stack, which is the result of the computation. This matches the result of the original expression, so the program is correct 33

Advantages 4 Instructions/word Stack Organized Processors Smallest Encoding Length Opcode 8-bits Opcode 8-bits Opcode 8-bits Opcode 8-bits 34

Push and Pop Push and Pop Instructions Push or Pop Opcode 8-bits Immediate Operands 24- bits 35

Summary 36

We learnt The operands and destination of an instruction in a stack-based organization implicit Instructions take fewer bits to encode than they do in general-purpose register organizations Stack organized processor instruction set Postfix notation for writing easily the instructions

End of Lesson 18 on Stack-based processor Organisation