Where we are going (today)

Similar documents
Where we are going (today)

Where we are going (today)

Where are we? Compiler. translating source code (C or Java) Programs to assembly language And linking your code to Library code

Bits, bytes and digital information. Lecture 2 COMPSCI111/111G

Overview. ELEC2041 Microprocessors and Interfacing. Lecture 7: Number Systems - II. March 2006.

CS 2630 Computer Organization. Meeting 13: Faster arithmetic and more operations Brandon Myers University of Iowa

CS61C : Machine Structures

Data III & Integers I

CS61c Midterm Review (fa06) Number representation and Floating points From your friendly reader

CS61C : Machine Structures

Data III & Integers I

Many ways to build logic out of MOSFETs

Introduction to the Use of Computers

Here is a diagram of a simple computer system: (this diagram will be the one needed for exams) CPU. cache

CS2630: Computer Organization Homework 1 Bits, bytes, and memory organization Due January 25, 2017, 11:59pm

Topic Notes: Bits and Bytes and Numbers

Are Computers Smart? To a programmer: Lecture #1 Introduction & Numbers Andy Carle. Are Computers Smart? What are Machine Structures?

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Bits, Bytes and Integers

COSC 6385 Computer Architecture. Storage Systems

Number Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers

Hardware: Logical View

CS 2630 Computer Organization. Meeting 4: Intro to Architecture (specifically, MIPS) Brandon Myers University of Iowa

Memory, Data, & Addressing I

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

CS 33. Data Representation, Part 1. CS33 Intro to Computer Systems VII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

large units some names for large numbers CIS 2107 Chapter 2 Notes Part 1

CIS 2107 Chapter 2 Notes Part 1. Representing and Manipulating Information

Topic Notes: Bits and Bytes and Numbers

CS 261 Fall Binary Information (convert to hex) Mike Lam, Professor

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

Under the Hood: Data Representations, Memory and Bit Operations. Computer Science 104 Lecture 3

Bits and Bytes. Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions

COSC 6385 Computer Architecture Storage Systems

CS 107 Lecture 2: Bits and Bytes (continued)

Bits and Bytes January 13, 2005

Bitwise Data Manipulation. Bitwise operations More on integers

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators

Integer Representation

Memory, Data, & Addressing II CSE 351 Spring

COSC 6374 Parallel Computation. Parallel I/O (I) I/O basics. Concept of a clusters

Survey. Motivation 29.5 / 40 class is required

ECE 250 / CS 250 Computer Architecture. C to Binary: Memory & Data Representations. Benjamin Lee

C expressions. (Reek, Ch. 5) 1 CS 3090: Safety Critical Programming in C

Data III & Integers I

CS61C : Machine Structures

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

378: Machine Organization and Assembly Language

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018

CS61C : Machine Structures

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2

C-string format with scanf/printf

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10?

C-string format with scanf/printf

CSCI2467: Systems Programming Concepts

CS 241 Data Organization Binary

Recap from Last Time. CSE 2021: Computer Organization. It s All about Numbers! 5/12/2011. Text Pictures Video clips Audio

Computer Organization & Systems Exam I Example Questions

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

EMBEDDED SYSTEMS. Part I: Introduction and Hardware

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

Review: ISA. Review: Compiling Applications. Computer Architecture ELEC3441. Instruction Set Architecture (1) Computer Architecture: HW/SW Interface

CSCI 2212: Intermediate Programming / C Chapter 15

Learning Programme Fundamentals of data representation AS Level

2.1. Unit 2. Integer Operations (Arithmetic, Overflow, Bitwise Logic, Shifting)

UW CSE 351, Winter 2013 Final Exam

Bits, Words, and Integers

Memory, Data, & Addressing II

CSE351: Memory, Data, & Addressing I

Topics of this Slideset. CS429: Computer Organization and Architecture. It s Bits All the Way Down. Why Binary? Why Not Decimal?

CS429: Computer Organization and Architecture

Representation of Information

4. Number Representations

Page 1. Logistics. Introduction to Embedded Systems. My Records Indicate. Intel 4004 first single chip computer? Acronyms CS/ECE 6780/5780.

Chapter 2A Instructions: Language of the Computer

UW CSE 351, Summer 2013 Final Exam

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #34. Function with pointer Argument

CS 2630 Computer Organization. Meeting 10/11: data structures in MIPS Brandon Myers University of Iowa

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers

MIPS Assembly: Practice Questions for Midterm 1 Saving to and Loading from Memory CS 64: Computer Organization and Design Logic Lecture #6

ECE2049 E17 Lecture 2: Data Representations & C Programming Basics

CS 110 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger.

Operations, Operands, and Instructions

Last time s big ideas

CPS 104 Computer Organization and Programming

2. Integers. 9 * celsius / Celsius to Fahrenheit. Precedence. (9 * celsius / 5) + 32

CS107, Lecture 3 Bits and Bytes; Bitwise Operators

Chapter 1. Computer Abstractions and Technology. Lesson 3: Understanding Performance

The MARIE Architecture

Learning the Binary System

2. Integers. 9 * celsius / Celsius to Fahrenheit. Precedence. (9 * celsius / 5) + 32

Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That

2. Integers. 9 * celsius / Celsius to Fahrenheit. Precedence. (9 * celsius / 5) + 32

Review 1/2 MIPS assembly language instructions mapped to numbers in 3 formats. CS61C Negative Numbers and Logical Operations R I J.

Slide Set 3. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

AGENDA Binary Operations CS 3330 Samira Khan

Data Representation and Storage. Some definitions (in C)

SIGNED AND UNSIGNED SYSTEMS

levels (layers) of abstraction

Transcription:

Where we are going (today) Q: How do we arrange bits in the memory of the computer? (why do we care? we want the computer to store many individual numbers) A: bytes and words 10110000 00001110 01000010 11110001 Q: How do we name or refer to all those individual numbers in memory? A: addresses and pointers 0 1 2 3 10110000 00001110 01000010 11110001 first second Bits store whatever you want, including integers. How do we manipulate sequences of bits? 10110000 Lab1

Where we are going Compiler Instruction set architecture (e.g., MIPS) translating source code (C or Java) Programs to assembly language And linking your code to Library code How the software talks To the hardware Memory system Processor Datapath & Control Digital logic I/O system How a processor runs MIPS Programs! How switches (1 or 0) can be used to build Interesting functions: from integer arithmetic to programmable computers

CS 2630 Computer Organization Meeting 3: memory organization and addresses Brandon Myers University of Iowa

Processor Instruction memory Execution engine Data memory organizes its bits as bytes and words

Organizing bits Byte: a unit of data In the MIPS architecture, bytes are 8-bits long and are the smallest unit of data the architecture gives a name to (more on names soon) True of most other modern architectures, too 00011010 1A 1 byte, perhaps storing the integer 26 10 We also like to write the value of a byte as two hex digits

Memory organization We think of memory as one big array of bytes 1A Analogy in Java? byte[] memory = new byte[num_bytes]; Just like every element in an array has an index, every byte in memory has an index, called its address. Use the address to find the byte to read or write it 1A

Just like every element in an array has an index, every byte in memory has an index, called its address. Use the address to find the byte to read or write it 1A Peer instruction: A MIPS computer has addresses that are 32-bit integers What is the largest number of bytes the memory of a MIPS computer can have?

How do I refer to an individual cow? Name it; like farmed cows, our bytes will have numbers as names http://www.publicdomainpictures.net/view-image.php?image=2759

Organize bytes into machine words (in this diagram, we are writing the address in hex) bytes (or, 8 bits) 0x0000 0x0001 0x0002 0x0003 1A 0x0004 0x0005 0x0006 0x0007 0x0008 0x0009 0x000A 0x000B 0x000C 0x000D 0x000E 0x000F 4-byte (or, 32 bits) words 8-byte (or, 64 bits) words

Where we are going (today) Bits store whatever you want, including integers. How do we manipulate sequences of bits? 10110000 Q: How do we arrange bits in the memory of the computer? (why do we care? we want the computer to store many individual numbers) A: bytes and words 10110000 00001110 01000010 11110001 Q: How do we name or refer to all those individual numbers in memory? A: addresses and pointers 0 1 2 3 10110000 00001110 01000010 11110001 done (for now) next

Looking at memory as words 0x00000000 0x00000004 0x00000008 0x0000000C 0x00000010 0x00000014 0x00000018 0x0000001C 0x00000020 0x00000024 0x00000028

Storing values store the value integer 15 10 at address 0x00000014 00 00 00 0F 0x00000000 0x00000004 0x00000008 0x0000000C 0x00000010 0x00000014 0x00000018 0x0000001C 0x00000020 0x00000024 0x00000028

Storing values store the value integer 15 10 at address 0x00000014 store the value integer 20 10 at address 0x00000000 00 00 00 14 00 00 00 0F 0x00000000 0x00000004 0x00000008 0x0000000C 0x00000010 0x00000014 0x00000018 0x0000001C 0x00000020 0x00000024 0x00000028

Addresses can be values, too! store the value integer 15 10 at address 0x00000014 store the value integer 20 10 at address 0x00000000 store the value address 0x0014 at address 0x0000001C 00 00 00 14 00 00 00 0F 00 00 00 14 0x00000000 0x00000004 0x00000008 0x0000000C 0x00000010 0x00000014 0x00000018 0x0000001C 0x00000020 0x00000024 0x00000028

Addresses can be values, too! store the value integer 15 10 at address 0x00000014 store the value integer 20 10 at address 0x00000000 store the value address 0x0014 at address 0x0000001C we say the word at address 0x001C is a pointer to the integer at address 0x0014 00 00 00 14 00 00 00 0F 00 00 00 14 0x00000000 0x00000004 0x00000008 0x0000000C 0x00000010 0x00000014 0x00000018 0x0000001C 0x00000020 0x00000024 0x00000028

Addresses can be values, too! store the value integer 15 10 at address 0x00000014 store the value integer 20 10 at address 0x00000000 store the value address 0x0014 at address 0x0000001C we say the word at address 0x0000001C is a pointer to the integer at address 0x00000014 store the value address 0x001C at address 0x00000028 we say the word at address 0x00000028 is a pointer to a pointer to an integer 00 00 00 14 00 00 00 0F 00 00 00 14 00 00 00 1C 0x00000000 0x00000004 0x00000008 0x0000000C 0x00000010 0x00000014 0x00000018 0x0000001C 0x00000020 0x00000024 0x00000028

Peer instruction 1. Draw this memory on the board 2. Fill in the memory so that the word at address 0x00000010 holds the integer 4096 10. 3. Fill in the memory so that the word at address 0x00000000 holds a pointer to the integer from question 2. 0x00000000 0x00000004 0x00000008 0x0000000C 0x00000010

Waitlist bring your Registrar form to me @today, OH, DebugYourBrain if you haven t already I will return some signed on Wednesday in class if seats are available

How arrays look in memory int[] arr = new int[3]; 0x0000 0x0004 0x0008 0x000C 0x0010 0x0014 0x0018 0x001C 0x0020 0x0024 0x0028

How arrays look in memory int[] arr = new int[3]; arr[0] = 13; 00 00 00 0D 0x0000 0x0004 0x0008 0x000C 0x0010 0x0014 0x0018 0x001C 0x0020 0x0024 0x0028

How arrays look in memory int[] arr = new int[3]; arr[0] = 13; arr[1] = 10; 00 00 00 0D 00 00 00 0A 0x0000 0x0004 0x0008 0x000C 0x0010 0x0014 0x0018 0x001C 0x0020 0x0024 0x0028

How arrays look in memory int[] arr = new int[3]; arr[0] = 13; arr[1] = 10; arr[2] = 16; 00 00 00 0D 00 00 00 0A 00 00 00 10 0x0000 0x0004 0x0008 0x000C 0x0010 0x0014 0x0018 0x001C 0x0020 0x0024 0x0028

Peer instruction Suppose we allocate this array: int[] arr = new int[7]; and Java decided to put the first byte of the array (first byte of arr[0]) at address 0x04 What is the address of arr[5]? a. 0x04 b. 0x14 c. 0x09 d. 0x54 e. 0x05 f. 0x18 address= base address + index * element_size https://b.socrative.com/login/student/ room name: CS2630 name is optional

Size of data types (in bytes) Java data type size in 32-bit architecture boolean 1 1 byte 1 1 short 2 2 int 4 4 long 8 8 float (later!) 4 4 reference (stores a memory address) 4 8 size in 64-bit architecture slide inspired by UW CSE351

Administrivia: Survey results...?

Slip days PER ASSIGNMENT result: 2

Slip days TOTAL result: 6

Aside: naming powers of two One of our favorite formulas: how many unique things can you represent with N bits? 2 N things Naming conventions N =? name Close (but not equal!) to power of 10 10 Kibi (Ki) 10 3 or Kilo (K) 20 Mebi (Mi) 10 6 or Mega (M) 30 Gibi (Gi) 10 9 or Giga (G) 40 Tebi (Ti) 10 12 or Tera (T) 50 Pebi (Pi) 10 15 or Peta (P) 60 Exbi (Ei) 10 18 or Exa (E) Name these numbers of bytes: 2 11 bytes = 2 32 bytes = 2 59 bytes =

Where we are going (today) Bits store whatever you want, including integers. How do we manipulate sequences of bits? 10110000 Q: How do we arrange bits in the memory of the computer? (why do we care? we want the computer to store many individual numbers) A: bytes and words 10110000 00001110 01000010 11110001 Q: How do we name or refer to all those individual numbers in memory? A: addresses and pointers 0 1 2 3 10110000 00001110 01000010 11110001 NEXT, Lab1 DONE (for now) DONE (for now)

What to do now Readings finish HW 1 finish Quiz 1 Pre-lab for Lab 1 on Wednesday

can do bitwise operations (and other stuff) Instruction memory Execution engine Data memory

Op 1. Changing the number of bits Often we need to change the number of bits we are using to store a number (why?) 12 10 using 4 bits is 1100 2 If we store it in 8 bits: 00001100 2-5 10 using 4 bits is: 1011 If we store it in 8 bits: 2 We call this operation sign extension: copy the leftmost bit in 4-bit number to the new 4 leftmost bits in the 8-bit number

Op 2. Bitwise operations Logical AND (&) 0011 1010 0010 XOR (^) 0011 1010 1001 Logical OR ( ) 0011 1010 1011 negate (~) 0110 1001

Representing sets with bits 4-bit vector represents subsets of {3,2,1,0} 1 means in the set, 0 means not in the set A is the set {1,0}, encoded as 0011 B is the set {2,0}, encoded as 0101 Set operations using bitwise operators A&B Intersection 0001 (1 iff both are 1) A B Union 0111 (1 iff at least one 1) A^B symmetric difference 0110 (1 iff exactly one 1) ~B complement 1010 (1 iff 0) slide inspired by UW CSE351

Op 3. Shift shift: move bits left or right Left shift: 6 << 2 (diagrams show that I am storing the integers using 5 bits) 0 0 1 1 0 1 1 0 0 0 Right shift: 6 >> 1 0 0 1 1 0 0 0 0 1 1

Peer instruction What is the integer result from evaluating each of the expressions? (assume integers are 32 bits) (7 << 2) & 15 (15 >> 2) 8 assume >> is right logical shift

Let s play a card game Come up with a binary encoding for a 52-card deck Operations on a pair of cards We want the following operations to be easy to implement Compare two cards, which is higher value? Compare two cards, are they the same suit? Slide inspired by CSE351 Spring 2016

Summary and what s next TODAY can do bitwise operations (and other stuff) Instruction memory Execution engine Data memory NEXT Stores programs! TODAY organizes its bits as bytes and words