CS41B MACHINE David Kauchak CS 52 – Fall 2015. Admin  Assignment 3  due Monday at 11:59pm  one small error in 5b (fast division) that’s been fixed.

Slides:



Advertisements
Similar presentations
ENGR2216 FORTRAN PROGRAMMING FOR ENGINEERS. Chapter 1 The computer CPU MEMORY INPUT/OUTPUT DEVICES DATA REPRESENTATION BINARY SYSTEM OCTAL & HEXADECIMAL.
Advertisements

 The central processing unit (CPU) interprets and executes instructions.  The “brains” of the computer.  The speed of the processor is how fast it.
Computer Structures Lecture 2: Working with 0’s and 1’s.
J. Michael Moore Computer Organization CSCE 110. J. Michael Moore High Level View Of A Computer ProcessorInputOutput Memory Storage.
Professor Jennifer Rexford COS 217
assumes basic arithmetic
Codes and number systems Introduction to Computer Yung-Yu Chuang with slides by Nisan & Schocken ( ) and Harris & Harris (DDCA)
Binary Representation - Shortcuts n Negation x + x = 1111…1111 two = -1 (in 2’s complement) Therefore, -x = x + 1 n Sign Extension o Positive numbers :
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510, Section 2.
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.
Number Representations and Computer Arithmetic. CS 21a 9/23/02 Odds and Ends Slide 2 © Luis F. G. Sarmenta and John Paul Vergara, Ateneo de Manila University.
Lecture 1. Number Systems Prof. Taeweon Suh Computer Science Education Korea University ECM585 Special Topics in Computer Design.
Number Systems Part 2 Numerical Overflow Right and Left Shifts Storage Methods Subtraction Ranges.
The Computer Systems By : Prabir Nandi Computer Instructor KV Lumding.
1 Machine Architecture and Number Systems Topics Major Computer Components Bits, Bytes, and Words The Decimal Number System The Binary Number System Converting.
Computer System & Binary Review. Memory Model What memory is supposed to look like.
CS 111 – Aug – 1.3 –Information arranged in memory –Types of memory –Disk properties Commitment for next day: –Read pp , In other.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510.
Lecture 2 “Structure of computer” Informatics. Computer is  general purpose device that can be programmed to carry out a set of arithmetic or logical.
Introduction to Computers
Copyright © 2003 by Prentice Hall Module 5 Central Processing Unit 1. Binary representation of data 2. The components of the CPU 3. CPU and Instruction.
Slide 1 Wednesday, October 07, 2015 Low Level Machine.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Machine Architecture CMSC 104, Section 4 Richard Chang 1.
The Central Processing Unit: What Goes on Inside the Computer
PYTHON PROGRAMING Week 15 – Tuesday.
CS41B MACHINE David Kauchak CS 52 – Fall Admin  Midterm Thursday  Review question sessions tonight and Wednesday  Assignment 3?  Assignment.
The Hexadecimal Number System and Memory Addressing ISAT 121.
Inside your computer. Hardware Review 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 Guts and Operating Systems CSCI 101 Week Two.
1 3 Computing System Fundamentals 3.2 Computer Architecture.
CSC 110 – Intro to Computing Lecture 8: Computing Components.
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.
Bits and Bytes IGCSE. A binary number is either a 0 or a 1 and is known as a 'bit' or b inary dig it. However, the CPU cannot deal with just one bit at.
DIGITAL CIRCUITS David Kauchak CS52 – Fall 2015.
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 Science Binary. Binary Code Remember the power supply that is inside your computer and how it sends electricity to all of the components? That.
Computer Architecture Memory, Math and Logic. Basic Building Blocks Seen: – Memory – Logic & Math.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
Data Representation Bits, Bytes, Binary, Hexadecimal.
How We Measure Memory. Learning Goal Today we are going to learn how the computer stores information.
Computers - The Journey Inside continues…
Thursday 8 th October, 2015 Information Technology Fundamentals of Hardware & Software.
How We Measure Memory. At the Bottom of things A piece of digital information is always stored as a sequence of binary states. What’s that mean you ask???
Monday, January 14 Homework #1 is posted on the website Homework #1 is posted on the website Due before class, Jan. 16 Due before class, Jan. 16.
CS 125 Lecture 2 Martin van Bommel. Hardware vs Software Hardware - physical components you can see and touch –e.g. processor, keyboard, disk drive Software.
Memory The term memory is referred to computer’s main memory, or RAM (Random Access Memory). RAM is the location where data and programs are stored (temporarily),
{ Binary “There are 10 types of people in the world: Those who understand binary, and those who don't.”
Binary & Hex Review.
Design of Digital Circuits Reading: Binary Numbers
David Kauchak CS 52 – Spring 2017
David Kauchak CS 52 – Spring 2017
3.1 Denary, Binary and Hexadecimal Number Systems
Introduction to Computer Architecture
David Kauchak CS 52 – Spring 2016
Computer Architecture
COMPUTER MEMORY & DATA STORAGE
COMPUTER MEMORY & DATA STORAGE
PRIMARY STORAGE.
Binary “There are 10 types of people in the world: Those who understand binary, and those who don't.”
Computer Organization
The Study of Computer Science
Information Technology Department
Comp Org & Assembly Lang
Binary & Hex Review.
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.
The Study of Computer Science Chapter 0
Presentation transcript:

CS41B MACHINE David Kauchak CS 52 – Fall 2015

Admin  Assignment 3  due Monday at 11:59pm  one small error in 5b (fast division) that’s been fixed  Midterm next Thursday in-class (10/1)  Comprehensive  Closed books, notes, computers, etc.  Except, may bring up to 2 pages of notes  Practice problems posted Also some practice problems in the Intro SML reading  Midterm review sessions Tuesday and Wednesday (Q&A session for midterm)

Midterm topics SML recursion math

Midterm topics  Basic syntax  SML built-in types  Defining function  pattern matching  Function type signatures  Recursion!  map  exceptions  Defining datatypes  addition, subtraction, multiplication manually and on list digits  Numbers in different bases  Binary number representation (first part of today’s lecture)  NOT CS41B material

Binary number revisited What number does 1001 represent in binary? Depends! Is it a signed number or unsigned? If signed, what convention are we using?

Twos complement For a number with n digits high order bit represents -2 n-1 unsigned signed (twos complement)

Twos complement What number is it? unsigned signed (twos complement)

Twos complement What number is it? unsigned signed (twos complement)

Twos complement What number is it? unsigned signed (twos complement)

Twos complement How many numbers can we represent with each approach using 4 bits? unsigned signed (twos complement) (2 4 ) numbers, 0000, 0001, …., 1111 Doesn’t matter the representation!

Twos complement How many numbers can we represent with each approach using 32 bits? unsigned signed (twos complement) ≈ 4 billion numbers

Twos complement What is the range of numbers we can represent for each approach? unsigned signed (twos complement) unsigned: 0, 1, … 15 signed: -8, -7, …, 7

binary representation unsigned ?

binary representation unsignedtwos complement 00000?

binary representation unsignedtwos complement ?

binary representation unsignedtwos complement ?

binary representation unsignedtwos complement

binary representation unsignedtwos complement How can you tell if a number is negative?

binary representation unsignedtwos complement High order bit!

A two’s complement trick You can also calculate the value of a negative number represented as twos complement as follows:  Flip all of the bits (0  1 and 1  0)  Add 1  Resulting number is the magnitude of the original negative number flip the bits add 1

A two’s complement trick You can also calculate the value of a negative number represented as twos complement as follows:  Flip all of the bits (0  1 and 1  0)  Add 1  Resulting number is the magnitude of the original negative number flip the bits add 1

Addition with twos complement numbers ?

Addition with twos complement numbers

Addition with twos complement numbers ?

Addition with twos complement numbers ? 1

Addition with twos complement numbers ? Overflow! We cannot represent this number (it’s too large)

Addition with twos complement numbers ?

Addition with twos complement numbers

Addition with twos complement numbers ignore the last carry

Subtraction Ideas?

Subtraction  Negate the 2 nd number (flip the bits and add 1)  Add them!

A two’s complement trick You can also calculate the value of a negative number represented as twos complement as follows:  Flip all of the bits (0  1 and 1  0)  Add 1  Resulting number is the magnitude of the original negative number Why does this work?

A two’s complement trick You can also calculate the value of a negative number represented as twos complement as follows:  Flip all of the bits (0  1 and 1  0)  Add 1  Resulting number is the magnitude of the original negative number What is: 0010 ?

Hexadecimal numbers Hexadecimal = base 16 What will be the digits?

Hexadecimal numbers Hexadecimal = base 16 Digits … 9 a (10) b (11) c (12) d (13) e (14) f (15) What number is 1ad?

Hexadecimal numbers Hexadecimal = base 16 Digits … 9 a (10) b (11) c (12) d (13) e (14) f (15) 1a d = *16+13= =

Hexadecimal numbers Hexadecimal = base 16 Digits … 9 a (10) b (11) c (12) d (13) e (14) f (15) Hexadecimal is common in CS. Why?

Hexadecimal numbers Hexadecimal = base 16 Digits … 9 a (10) b (11) c (12) d (13) e (14) f (15) Hexadecimal is common in CS. 4 bits = 1 hexadecimal digit What is the following number in hex?

Hexadecimal numbers Hexadecimal = base 16 Digits … 9 a (10) b (11) c (12) d (13) e (14) f (15) Hexadecimal is common in CS. 4 bits = 1 hexadecimal digit What is the following number in hex? d51

Computer internals

Computer internals simplified What does it stand for? What does it do? CPURAM What does it stand for? What does it do?

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

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

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

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

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

Memory speed operationaccess timetimes slower than register access for comparison … register0.3 ns11 s RAM120 ns4006 min Hard disk1ms~million1 month google.com0.4s~billion30 years

Memory RAM … What is a byte? ?

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

Memory sizes bits byte8 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 bits byte8 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 address 0123…0123…

Memory RAM … Memory is organized into “words”, which is the most common functional unit address 0123…0123…

Memory RAM … Most modern computers use 32-bit (4 byte) or 64-bit (8 byte) words address bit words

Memory in the CS41B Machine RAM … We’ll use 16-bit words for our model (the CS41B machine) address bit words

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

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

operation name (always three characters)

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

operation function dest = first register src0 = second register src1 = third register arg = number/argument

add r1 r2 r3 What does this do?

add r1 r2 r3 r1 = r2 + r3 Add contents of registers r2 and r3 and store the result in r1

adc r2 r1 10 What does this do?

adc r2 r1 10 r2 = r Add 10 to the contents of register r1 and store in r2

adc r1 r0 8 neg r2 r1 sub r2 r1 r2 What number is in r2?

adc r1 r0 8 neg r2 r1 sub r2 r1 r2 r1 = 8 r2 = -8, r1 = 8 r2 = 16