David Kauchak CS 52 – Spring 2017

Slides:



Advertisements
Similar presentations
Hardware Lesson 3 Inside your computer.
Advertisements

Chapter 2 Machine Language.
Computer Hardware.
1BA3 G Lacey Lecture 51 Evaluating mathematical expressions  How do computers evaluate x + y or any mathematical expression ?  Answer : “Reverse Polish.
Chapter 2 Machine Language. Machine language The only language a computer can understand directly. Each type of computer has its own unique machine language.
2 pt 3 pt 4 pt 5pt 1 pt 2 pt 3 pt 4 pt 5 pt 1 pt 2pt 3 pt 4pt 5 pt 1pt 2pt 3 pt 4 pt 5 pt 1 pt 2 pt 3 pt 4pt 5 pt 1pt Category1 Computers Category2 CPU.
Chapter 0 Introduction to Computing
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,
How Computers Work. A computer is a machine f or the storage and processing of information. Computers consist of hardware (what you can touch) and software.
Aug CMSC 104, LECT-021 Machine Architecture and Number Systems Some material in this presentation is borrowed form Adrian Ilie From The UNIVERSITY.
Georgia Institute of Technology Introduction to Programming Part 2 Barb Ericson Georgia Institute of Technology May 2006.
Computers Central Processor Unit. Basic Computer System MAIN MEMORY ALUCNTL..... BUS CONTROLLER Processor I/O moduleInterconnections BUS Memory.
The Computer Systems By : Prabir Nandi Computer Instructor KV Lumding.
Chapter Two Hardware Basics: Inside the Box. ©1999 Addison Wesley Longman2.2 Chapter Outline What Computers Do A Bit About Bits The Computer’s Core: CPU.
CS 111 – Aug – 1.3 –Information arranged in memory –Types of memory –Disk properties Commitment for next day: –Read pp , In other.
MAC OS – Unit A Page: 10-11, Investigating Data Processing Understanding Memory.
Lecture 2 “Structure of computer” Informatics. Computer is  general purpose device that can be programmed to carry out a set of arithmetic or logical.
Personal Computer Adapted by Dr. Semmes from Mrs. Jungman’s Hardware Presentation and Mrs. Belisle’s Class Notes.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Computer Parts. Two Basic Parts Hardware & Software.
Intro to Computers Computer Apps 1.
CS41B MACHINE David Kauchak CS 52 – Fall Admin  Midterm Thursday  Review question sessions tonight and Wednesday  Assignment 3?  Assignment.
Inside your computer. Hardware Review Motherboard Processor / CPU Bus Bios chip Memory Hard drive Video Card Sound Card Monitor/printer Ports.
Inside your computer. Hardware Motherboard Processor / CPU Bus Bios chip Memory Hard drive Video Card Sound Card Monitor/printer Ports.
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.
Computer Basics Terminology - Take Notes. What is a computer? well, what is the technical definition A computer is a machine that changes information.
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 Guts and Operating Systems CSCI 101 Week Two.
IT Groundwork ICS3UC - Unit 1 Hardware. Overview of Computer System.
BAT3O / BTX4C. Definition: A computer is an electronic machine that 1) takes in data and instructions (input) 2) works with the data (processing) 3) puts.
CS41B MACHINE David Kauchak CS 52 – Fall Admin  Assignment 3  due Monday at 11:59pm  one small error in 5b (fast division) that’s been fixed.
CPU How It Works. 2 Generic Block Diagram CPU MemoryInputOutput Address Bus Data Bus.
Computer Organization & Assembly Language © by DR. M. Amer.
Computer Architecture Memory, Math and Logic. Basic Building Blocks Seen: – Memory – Logic & Math.
Computer Studies/ICT SS2
Computers - The Journey Inside continues…
Computer Organization 1 Instruction Fetch and Execute.
Assessment Covering… Von Neuman architecture Registers – purpose and use, the fetch execute cycle.
The Computer System CS 103: Computers and Application Software.
Excellence Publication Co. Ltd. Volume Volume 1.
Basic Computer Organization Rashedul Hasan.. Five basic operation No matter what shape, size, cost and speed of computer we are talking about, all computer.
Basic Computer Components Unit 2. What is a computer?  A computer is an electronic device that accepts raw data and processes it into information that.
Information Technology (IT). Information Technology – technology used to create, store, exchange, and use information in its various forms (business data,
Basic Computer Fundamentals
The Study of Computer Science Chapter 0
Hardware specifications
Introduction to Programming Part 2
Introduction to Computer Architecture
The Study of Computer Science Chapter 0
David Kauchak CS 52 – Spring 2016
Microprocessor and Assembly Language
CS41B recursion David Kauchak CS 52 – Fall 2015.
Computer Architecture
COMPUTER MEMORY & DATA STORAGE
COMPUTER MEMORY & DATA STORAGE
The Study of Computer Science
CSCE Fall 2013 Prof. Jennifer L. Welch.
Computer Hardware.
Introduction to Programming Part 2
The Study of Computer Science
The Von Neumann Architecture Odds and Ends
CSCE Fall 2012 Prof. Jennifer L. Welch.
The Von Neumann Architecture
Information Technology Department
Year 10 Computer Science Hardware - CPU and RAM.
Basic components Instruction processing
AS Level ICT Selection and use of storage requirements, media, and devices: storage and storage capacity Unit 1 Topic a - Selection and use of storage.
Basic Computer Organization
Presentation transcript:

David Kauchak CS 52 – Spring 2017 CS52 machine David Kauchak CS 52 – Spring 2017

Admin Midterm 1 Assignment 3 Assignment 4

Examples from this lecture http://www.cs.pomona.edu/~dkauchak/classes/cs52/examples/cs52machine/

Computer internals

Computer internals simplified CPU RAM What does it stand for? What does it do? What does it stand for? What does it do?

Computer internals simplified CPU RAM (Central Processing Unit, aka “the processor”) (Random Access Memory, aka “memory” or “main memory”) Does all the work! Temporary storage

Computer internals simplified “the computer” hard drive CPU RAM Why do we need a hard drive?

Computer internals simplified “the computer” hard drive CPU RAM Persistent memory RAM only stores data while it has power

Computer simplified CPU RAM “the computer” hard drive network media drive input devices display

Inside the CPU CPU processor: does the work registers: local, fast memory slots … registers Why all these levels of memory?

Memory speed operation access time times slower than register access for comparison… register 0.3 ns 1 1 s RAM 120 ns 400 6 min Hard disk 1ms ~million 1 month google.com 0.4s ~billion 30 years

Memory RAM 010101111000101000010010 … What is a byte? ?

Memory RAM 01010111 10001010 00010010 … byte = 8 bits byte is abbreviated as B My laptop has 16GB (gigabytes) of memory. How many bits is that?

Memory sizes bits byte 8 kilobyte (KB) 2^10 bytes = ~8,000 megabyte (MB) 2^20 =~ 8 million gigabyte (GB) 2^30 = ~8 billion My laptop has 16GB (gigabytes) of memory. How many bits is that?

Memory sizes ~128 billion bits! bits byte 8 kilobyte (KB) 2^10 bytes = ~8,000 megabyte (MB) 2^20 =~ 8 million gigabyte (GB) 2^30 = ~8 billion ~128 billion bits!

Memory RAM Memory is byte addressable 1 2 3 … 01010111 10001010 1 2 3 … 01010111 10001010 00010010 01011010 … RAM Memory is byte addressable

Memory address 1 2 3 … 01010111 10001010 00010010 01011010 … RAM Memory is organized into “words”, which is the most common functional unit

Memory address 32-bit words 4 8 ... 10101011 10001010 00010010 01011010 11001011 00001110 01010010 01010110 10111011 10010010 00000000 01110100 … RAM Most modern computers use 32-bit (4 byte) or 64-bit (8 byte) words

Memory in the CS52 Machine address 16-bit words 2 4 ... 10101011 10001010 00010010 01011010 11001011 00001110 … RAM We’ll use 16-bit words for our model (the CS52 machine)

CS52 machine CPU instruction counter (location in memory of the next instruction in memory) processor ic r0 holds the value 0 (read only) r1 general purpose read/write r2 registers r3

instruction counter (location in memory of the next instruction in memory) ic r0 holds the value 0 (read only) r1 general purpose read/write r2 r3

CS52 machine instructions CPU processor What types of operations might we want to do (think really basic)? registers

CS52 machine code Four main types of instructions math branch/conditionals memory control the machine (e.g. stop it)

instruction name arguments

instruction/operation name (always three characters) instruction name arguments instruction/operation name (always three characters)

S = signed number (byte) instruction name arguments operation arguments R = register (e.g. r0) S = signed number (byte)

1st R: register where the answer will go instruction name arguments 1st R: register where the answer will go 2nd R: register of first operand 3rd S/R: register/value of second operand

1st R: register where the answer will go add r1 r2 r3 What does this do? 1st R: register where the answer will go 2nd R: register of first operand 3rd S/R: register/value of second operand

1st R: register where the answer will go add r1 r2 r3 r1 = r2 + r3 Add contents of registers r2 and r3 and store the result in r1 1st R: register where the answer will go 2nd R: register of first operand 3rd S/R: register/value of second operand

1st R: register where the answer will go add r2 r1 10 What does this do? 1st R: register where the answer will go 2nd R: register of first operand 3rd S/R: register/value of second operand

1st R: register where the answer will go add r2 r1 10 r2 = r1 + 10 Add 10 to the contents of register r1 and store in r2 1st R: register where the answer will go 2nd R: register of first operand 3rd S/R: register/value of second operand

1st R: register where the answer will go add r1 r0 8 neg r2 r1 sub r2 r1 r2 What number is in r2? 1st R: register where the answer will go 2nd R: register of first operand 3rd S/R: register/value of second operand

1st R: register where the answer will go add r1 r0 8 neg r2 r1 sub r2 r1 r2 r1 = 8 r2 = -8, r1 = 8 r2 = 16 1st R: register where the answer will go 2nd R: register of first operand 3rd S/R: register/value of second operand

Accessing memory sto = save data in register TO memory loa = put data FROM memory into a register sto r1 r2 ; store the contents of r1 to mem[r2] loa r1 r2 ; get data from mem[r2] and put into r1

Accessing memory sto = save data in register TO memory loa = put data FROM memory into a register Special cases: saving TO (sto) address 0 prints reading from (loa) address 0 gets input from user

Basic structure of CS52 program ; great comments at the top! ; instruction1 ; comment instruction2 ; comment ... hlt whitespace before operations/instructions

Running the CS52 machine Look at subtract.a52 load two numbers from the user subtract print the result

CS52 simulator Different windows Memory (left) Instruction execution (right) Registers I/O and running program

1st R: first register for comparison 2nd R: second register in comparison 3rd B: label

1st R: first register for comparison beq r3 r0 done What does this do? 1st R: first register for comparison 2nd R: second register in comparison 3rd B: label

1st R: first register for comparison beq r3 r0 done If r3 = 0, branch to the label “done” if not (else) ic is incremented as normal to the next instruction 1st R: first register for comparison 2nd R: second register in comparison 3rd B: label

1st R: first register for comparison ble r2 r3 done What does this do? 1st R: first register for comparison 2nd R: second register in comparison 3rd B: label

1st R: first register for comparison ble r2 r3 done If r2 <= r3, branch to the label done 1st R: first register for comparison 2nd R: second register in comparison 3rd B: label

Conditionals Loops Change the order that instructions are executed

CS52 machine execution

Basic structure of CS52 program ; great comments at the top! ; instruction1 ; comment instruction2 ; comment ... label1 instruction ; comment label2 hlt end - whitespace before operations/instructions - labels go here

More CS52 examples Look at max_simple.a52 Get two values from the user Compare them Use a branch to distinguish between the two cases Goal is to get largest value in r3 print largest value