1BA3 G Lacey Lecture 51 Evaluating mathematical expressions  How do computers evaluate x + y or any mathematical expression ?  Answer : “Reverse Polish.

Slides:



Advertisements
Similar presentations
Computer Memory and Data Transfer
Advertisements

What is memory? Memory is used to store information within a computer, either programs or data. Programs and data cannot be used directly from a disk or.
Intermediate GNVQ ICT Computer Systems Hardware is the name that is given to any part of a computer that you can actually touch. An individual piece of.
©Brooks/Cole, 2003 Chapter 5 Computer Organization.
Chapter 0 Introduction to Computing
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Computer Systems CS208. Major Components of a Computer System Processor (CPU) Runs program instructions Main Memory Storage for running programs and current.
Memory. When we receive some instruction or information we retain them in our memory. Similarly a computer stores the instructions for solving a problem,
Lecture 18 Last Lecture Today’s Topic Instruction formats
Atmega32 Architectural Overview
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
Computer Organization
Memory Main memory consists of a number of storage locations, each of which is identified by a unique address The ability of the CPU to identify each location.
Topics Introduction Hardware and Software How Computers Store Data
E0001 Computers in Engineering1 The System Unit & Memory.
The Computer Systems By : Prabir Nandi Computer Instructor KV Lumding.
Random access memory.
1 Machine Architecture and Number Systems Topics Major Computer Components Bits, Bytes, and Words The Decimal Number System The Binary Number System Converting.
Lecture 17 Today’s Lecture –Instruction formats Little versus big endian Internal storage in the CPU: stacks vs. registers Number of operands and instruction.
Three fundamental concepts in computer security: Reference Monitors: An access control concept that refers to an abstract machine that mediates all accesses.
Hardware Data Storage.
Computers organization & Assembly Language Chapter 0 INTRODUCTION TO COMPUTING Basic Concepts.
Machine Architecture CMSC 104, Section 4 Richard Chang 1.
GCSE Information Technology Storing data Data storage devices can be divided into 2 main categories: Backing storage is used to store programs and data.
Components of a Computer Prepared by: Mrs. McCallum-Rodney.
Microcode Source: Digital Computer Electronics (Malvino and Brown)
20-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept lecture7-8-compstate 1 Machine Organization  Systems (including.
CSC 3210 Computer Organization and Programming Chapter 1 THE COMPUTER D.M. Rasanjalee Himali.
Chidambaranathan C.M SRM University,Haryana. Memory:- As the word implies “memory” means the place where we have to store any thing, this is very essential.
Introduction to Computer Architecture. What is binary? We use the decimal (base 10) number system Binary is the base 2 number system Ten different numbers.
GCSE Information Technology Computer Systems 2 Hardware is the name that is given to any part of a computer that you can actually touch. An individual.
Computer Architecture Lecture 24 Fasih ur Rehman.
Computer Organization. The digital computer is a digital system that performs various computational tasks Digital computer use binary number system which.
Computer Organization 1 Instruction Fetch and Execute.
Thursday 8 th October, 2015 Information Technology Fundamentals of Hardware & Software.
Computer Systems. Bits Computers represent information as patterns of bits A bit (binary digit) is either 0 or 1 –binary  “two states” true and false,
CHP-3 STACKS.
BMTS 242: Computer and Systems Lecture 2: Memory, and Software Yousef Alharbi Website
PHY 201 (Blum)1 Stacks Based in part on material from Chapters 4 & 5 in Computer Architecture by Nicholas Carter.
Main Memory Main memory – –a collection of storage locations, –each with a unique identifier called the address. Word- –Data are transferred to and from.
Von Neumann Machines. 3 The Von Neumann Architecture Model for designing and building computers, based on the following three characteristics: 1)The.
Logic Gates Dr.Ahmed Bayoumi Dr.Shady Elmashad. Objectives  Identify the basic gates and describe the behavior of each  Combine basic gates into circuits.
Introduction To Computer Programming – 1A Computer Parts, Words, and Definition Herriman High School.
Information Technology (IT). Information Technology – technology used to create, store, exchange, and use information in its various forms (business data,
CPU Lesson 2.
STORAGE DEVICES Towards the end of this unit you will be able to identify the type of storage devices and their storage capacity.
David Kauchak CS 52 – Spring 2017
Topics Introduction Hardware and Software How Computers Store Data
COMPSCI 107 Computer Science Fundamentals
Programming in Machine Language
Storage Hardware This icon indicates the slide contains activities created in Flash. These activities are not editable. For more detailed instructions,
STORAGE DEVICES Towards the end of this unit you will be able to identify the type of storage devices and their storage capacity.
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
PRIMARY STORAGE.
STORAGE DEVICES Towards the end of this unit you will be able to identify the type of storage devices and their storage capacity.
Chapter One: Introduction
Topics Introduction Hardware and Software How Computers Store Data
Queue Applications Lecture 31 Mon, Apr 9, 2007.
Overview 1. Inside a PC 2. The Motherboard 3. RAM the 'brains' 4. ROM
Information Technology Department
Queue Applications Lecture 31 Tue, Apr 11, 2006.
Presented by : Aman Gupta PGT CS KV No.1, Narimedu, Madurai
Stacks A stack is an ordered set of elements, for which only the last element placed into the stack is accessible. The stack data type is also known as.
Presentation transcript:

1BA3 G Lacey Lecture 51 Evaluating mathematical expressions  How do computers evaluate x + y or any mathematical expression ?  Answer : “Reverse Polish Notation”  a + b - c / ( d + e ) is an infix expression a, b, c, d, and e are operands +, -, /, “(“, and “)” are operators  Computers can’t evaluate infix expressions. They must first be converted to “reverse polish notation” or postfix expressions  a b + c d e + / -is a postfix expression

1BA3 G Lacey Lecture 52 Push onto stack  A data structure called a “stack” is used to convert infix to postfix  A stack is like a packet of PEZ or a coin holder on the Bus i.e. “last in = first out”  Things can only be put onto the top of the stack (push)  Things can only be taken from the top of the stack (pop)  Push a, b, c, d, e onto the stack  Pop 3 items off the stack Top of Stack ab

1BA3 G Lacey Lecture 53 Push onto stack  A data structure called a “stack” is used to convert infix to postfix  A stack is like a packet of PEZ or a coin holder on the Bus i.e. “last in = first out”  Things can only be put onto the top of the stack (push)  Things can only be taken from the top of the stack (pop)  Push a, b, c, d, e onto the stack  Pop 3 items off the stack Top of Stack a b c

1BA3 G Lacey Lecture 54 Push onto stack  A data structure called a “stack” is used to convert infix to postfix  A stack is like a packet of PEZ or a coin holder on the Bus i.e. “last in = first out”  Things can only be put onto the top of the stack (push)  Things can only be taken from the top of the stack (pop)  Push a, b, c, d, e onto the stack  Pop 3 items off the stack Top of Stack a b cd

1BA3 G Lacey Lecture 55 Push onto stack  A data structure called a “stack” is used to convert infix to postfix  A stack is like a packet of PEZ or a coin holder on the Bus i.e. “last in = first out”  Things can only be put onto the top of the stack (push)  Things can only be taken from the top of the stack (pop)  Push a, b, c, d, e onto the stack  Pop 3 items off the stack Top of Stack a b c de

1BA3 G Lacey Lecture 56 Pop off stack  A data structure called a “stack” is used to convert infix to postfix  A stack is like a packet of PEZ or a coin holder on the Bus i.e. “last in = first out”  Things can only be put onto the top of the stack (push)  Things can only be taken from the top of the stack (pop)  Push a, b, c, d, e onto the stack  Pop 3 items off the stack Top of Stack a b c d e

1BA3 G Lacey Lecture 57 Pop off stack  A data structure called a “stack” is used to convert infix to postfix  A stack is like a packet of PEZ or a coin holder on the Bus i.e. “last in = first out”  Things can only be put onto the top of the stack (push)  Things can only be taken from the top of the stack (pop)  Push a, b, c, d, e onto the stack  Pop 3 items off the stack Top of Stack a b c d

1BA3 G Lacey Lecture 58 Pop off stack  A data structure called a “stack” is used to convert infix to postfix  A stack is like a packet of PEZ or a coin holder on the Bus i.e. “last in = first out”  Things can only be put onto the top of the stack (push)  Things can only be taken from the top of the stack (pop)  Push a, b, c, d, e onto the stack  Pop 3 items off the stack Top of Stack a b c

1BA3 G Lacey Lecture 59 Advantages of Stacks  Very simple to use  Use very little space  Only simple machine language instructions needed to implement a stack thus they can run very fast  Algorithm to convert from infix to postfix is simple  Algorithm to evaluate postfix is simple

1BA3 G Lacey Lecture 510 Convert a + b - c / ( d + e ) to Postfix  Algorithm : Place parentheses around the expression ( a + b - c / ( d - e ) ) moving left to right until the end of the infix expression  if the item is a number put into the post fix expression  if the item is an open brace push it onto the stack  if the item is an operator pop all operators of lower and equal precedence off of the stack and place them in the postfix expression, then push the operator onto the stack  If the operator is a close brace pop all operators off the stack until an open brace, then delete POSTFIX EXPRESSION = ()( a

1BA3 G Lacey Lecture 511 Convert a + b - c / ( d + e ) to Postfix  Algorithm : Place parentheses around the expression ( a + b - c / ( d - e ) ) moving left to right until the end of the infix expression  if the item is a number put into the post fix expression  if the item is an open brace push it onto the stack  if the item is an operator pop all operators of lower and equal precedence off of the stack and place them in the postfix expression, then push the operator onto the stack  If the operator is a close brace pop all operators off the stack until an open brace, then delete POSTFIX EXPRESSION = ()( a ( +

1BA3 G Lacey Lecture 512 Convert a + b - c / ( d + e ) to Postfix  Algorithm : Place parentheses around the expression ( a + b - c / ( d - e ) ) moving left to right until the end of the infix expression  if the item is a number put into the post fix expression  if the item is an open brace push it onto the stack  if the item is an operator pop all operators of lower and equal precedence off of the stack and place them in the postfix expression, then push the operator onto the stack  If the operator is a close brace pop all operators off the stack until an open brace, then delete POSTFIX EXPRESSION = ()( a ( + b -

1BA3 G Lacey Lecture 513  Algorithm : Place parentheses around the expression ( a + b - c / ( d - e ) ) moving left to right until the end of the infix expression  if the item is a number put into the post fix expression  if the item is an open brace push it onto the stack  if the item is an operator pop all operators of lower and equal precedence off of the stack and place them in the postfix expression, then push the operator onto the stack  If the operator is a close brace pop all operators off the stack until an open brace, then delete Convert a + b - c / ( d + e ) to Postfix POSTFIX EXPRESSION = ()( a ( + b - c/

1BA3 G Lacey Lecture 514  Algorithm : Place parentheses around the expression ( a + b - c / ( d - e ) ) moving left to right until the end of the infix expression  if the item is a number put into the post fix expression  if the item is an open brace push it onto the stack  if the item is an operator pop all operators of lower and equal precedence off of the stack and place them in the postfix expression, then push the operator onto the stack  If the operator is a close brace pop all operators off the stack until an open brace, then delete Convert a + b - c / ( d + e ) to Postfix POSTFIX EXPRESSION = ()( ab+c- ( ( / d

1BA3 G Lacey Lecture 515  Algorithm : Place parentheses around the expression ( a + b - c / ( d - e ) ) moving left to right until the end of the infix expression  if the item is a number put into the post fix expression  if the item is an open brace push it onto the stack  if the item is an operator pop all operators of lower and equal precedence off of the stack and place them in the postfix expression, then push the operator onto the stack  If the operator is a close brace pop all operators off the stack until an open brace, then delete Convert a + b - c / ( d + e ) to Postfix POSTFIX EXPRESSION = ()( ab+c-d ( ( / +e

1BA3 G Lacey Lecture 516  Algorithm : Place parentheses around the expression ( a + b - c / ( d - e ) ) moving left to right until the end of the infix expression  if the item is a number put into the post fix expression  if the item is an open brace push it onto the stack  if the item is an operator pop all operators of lower and equal precedence off of the stack and place them in the postfix expression, then push the operator onto the stack  If the operator is a close brace pop all operators off the stack until an open brace, then delete Convert a + b - c / ( d + e ) to Postfix POSTFIX EXPRESSION = ()( ab+c-de ( ( /

1BA3 G Lacey Lecture 517  Algorithm : Place parentheses around the expression ( a + b - c / ( d - e ) ) moving left to right until the end of the infix expression  if the item is a number put into the post fix expression  if the item is an open brace push it onto the stack  if the item is an operator pop all operators of lower and equal precedence off of the stack and place them in the postfix expression, then push the operator onto the stack  If the operator is a close brace pop all operators off the stack until an open brace, then delete Convert a + b - c / ( d + e ) to Postfix POSTFIX EXPRESSION = ()( ab+c-de/ ( (

1BA3 G Lacey Lecture 518 Evaluate / * Algorithm : Moving left to right along the post fix expression if the item is a number push it onto the stack if the item is an operator pop two numbers from the stack, execute the operator and push the result back onto the stack when no more items in the postfix string pop the answer off the stack ! + + / *

1BA3 G Lacey Lecture 519 Summary of Simple to SML  Concept High Level Language (HLL) translated into Machine Language by a compiler  Production rules translate Simple statements into SML  Code and Data space must be allocated  Maths equations need a more complex rule A sequence of rules – an algorithm The “Stack” data structure is used by the algorithm to convert infix maths expressions into postfix  A stack is also used to evaluate maths expressions  We will return to stacks later in the course

20 From Simpletron to 68332

1BA3 G Lacey Lecture 521 Basic Computer Architecture

1BA3 G Lacey Lecture 522 Simple Overview of the MC6800 The MC6800/MC68332 CPU has: 8 x 32-bit Data Register, D1 to D7 8 x 32-bit Address Register, A1 to A7 1 x 32-bit Program Counter, PC 1 x 16-bit Instruction Register, IR 1 x 16-bit Status Register, SR During one memory access the CPU can access 1 word (16-bit Data Bus). The Program Counter is 32 bits wide, but only 24 bits are used on the Robot (24-bit Address Bus).

1BA3 G Lacey Lecture 523 The MC6800 CPU

1BA3 G Lacey Lecture 524 The Unit of Memory The fundamental unit of memory is the BIT (Binary Digit) Each bit can take on the value Logic-1 or Logic-0 Accessing these bits individually is not of great use Each value can only be a Logic-1 or Logic-0 (not very useful for storing large numbers!)

1BA3 G Lacey Lecture 525 Group BITs Together View memory as a list of larger elements: 4 bits = 1 NYBBLE 8 bits = 1 BYTE 16 bits = 1 WORD 32 bits = 1 LONGWORD When reading data/writing data to/from memory (using the MC68332), we can do so in units of bytes, words or longwords only

1BA3 G Lacey Lecture 526 Data Bus The number of bits that can be read at any given time is determent by the BUS SIZE. BUS SIZE = Number of wires (data) connecting the CPU to the Memory

1BA3 G Lacey Lecture 527 Memory Capacity Memory size is expressed in terms of bytes: 1024 Bytes = 1 KILOBYTE (Kb.) 1024 Kilobytes = 1 MEGABYTE (Mb.) 1024 Megabyte = 1 GIGABYTE (Gb.) Individual bytes in memory (memory locations) are numbered sequentially.

1BA3 G Lacey Lecture 528 Types of Memory: CPU allowed to read and write contents of memory. Commonly known as Random Access Memory [RAM], 2 flavours: Volatile: contents lost when power is switched off. Non-Volatile: holds contents when power is switched off on computer Read Only Memory [ROM]: memory contents are physically etched onto the chip during manufacture. Contents can only be read, and are not lost on power-off.

1BA3 G Lacey Lecture 529 More Memory Types Programmable ROM [PROM]: can write contents into it ONCE only (using a device called a PROM Programmer). Henceforth, it acts like ROM. Erasable PROM [EPROM]: a PROM chip that may be written a number of times using an EPROM programmer Electrically Erasable PROM [EEPROM] sometimes called FLASH The robot has: 64Kb RAM 64Kb EPROM

1BA3 G Lacey Lecture 530 Memory Location The number of a memory location is it’s address E.g.: The contents of memory location 3 is 67.

1BA3 G Lacey Lecture 531 Bit Group Encoding Bit 3Bit 2Bit = = = = = = = = = = = = = = = = 15 2 nd Lecture, 1BA3, M. Manzke, Page: 31

1BA3 G Lacey Lecture 532 Memory - Address - Bit Address: 3,Bit: 7,6,5,4,3,2,1, etc.

1BA3 G Lacey Lecture 533 Operating Systems  A computer without software cannot: Load and run programs from disk Perform I/O (Input/Output) Handle situations where the software to run requires more memory than is physically available on the computer  An Operating System = A Program which insulates the user from the technical detail of the machine.

1BA3 G Lacey Lecture 534 The MONITOR Michael Manzke, Page: 34 A MONITOR is the simplest form of operating system. It is designed with a minimal specification and allows execution of low level assembly language programs. The monitor is a program (written in assembly language) which provides an interface to the CPU. Using knowledge from this course, you will write your own monitor in second year for a computer system (similar to the Robot) that you will design and build.

1BA3 G Lacey Lecture 535 Monitor provides functions to allow:  Writing and editing assembly language code  Assembling of code to machine language  Execution of software  Reading/Writing memory and CPU registers  Connecting to external computer systems for saving and loading of code  Debugging

1BA3 G Lacey Lecture 536 Robot Development System Michael Manzke, Page: 36  The RDS contains an Editor: used for writing and saving assembly code Assembler Downloader: loads code onto robot Debugger Terminal emulator: communicates with robot for I/O

1BA3 G Lacey Lecture 537 Robot Development System  All software is written/saved on the PC.  Programs are downloaded and executed on the Robot.  The Robot monitor does not allow editing/assembling or saving/printing.  The monitor is saved in ROM  monitor remains even if the power is off.  User programs saved in RAM  program lost when power off.

1BA3 G Lacey Lecture 538 Terminal Emulator The TE handles direct communication with the Robot. Every key hit in the TE is sent to the robot. Robot responds with messages which are printed in the TE window.

1BA3 G Lacey Lecture 539 Development System Software

1BA3 G Lacey Lecture 540 Development Cycle

1BA3 G Lacey Lecture 541 How can the monitor and my program run at the same time?  Answer: they don’t. Only one program can run at any given time on the CPU Monitor stops when user program is run. Monitor starts again when user program terminates (hopefully!).

1BA3 G Lacey Lecture 542 Program Execution  How does the CPU execute code? The program will exist as numbers in memory The CPU must be told which program to execute (i.e. where code exists in memory - > memory location)