Roadmap C: Java: Assembly language: OS: Machine code: Computer system:

Slides:



Advertisements
Similar presentations
University of Washington Roadmap 1 car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100);
Advertisements

University of Washington Roadmap 1 car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100);
University of Washington Memory and Caches I The Hardware/Software Interface CSE351 Winter 2013.
University of Washington Announcements Lab 1, how is it going? Accounts all set? Coursecast Readings! Before class! 1.
University of Washington Today Finished up virtual memory On to memory allocation Lab 3 grades up HW 4 up later today. Lab 5 out (this afternoon): time.
University of Washington Integers The Hardware/Software Interface CSE351 Winter 2013.
Roadmap C: Java: Assembly language: OS: Machine code: Computer system:
Today How’s Lab 1 going? Some of these are tricky (for us too)
University of Washington Exceptional Control Flow The Hardware/Software Interface CSE351 Winter 2013.
University of Washington Roadmap 1 car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100);
University of Washington Today Midterm topics end here. HW 2 is due Wednesday: great midterm review. Lab 3 is posted. Due next Wednesday (July 31)  Time.
University of Washington Roadmap car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100);
University of Washington Floating-Point Numbers The Hardware/Software Interface CSE351 Winter 2013.
Spring 2016Assembly Review Roadmap 1 car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100);
University of Washington Roadmap 1 car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100);
Spring 2016Machine Code & C Roadmap 1 car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100);
Java and C I CSE 351 Spring 2017 Instructor: Ruth Anderson
Assembly Programming I CSE 351 Spring 2017
Floats! Coursecast on! Today:
Java and C II CSE 351 Spring 2017 Instructor: Ruth Anderson
Final exam: Wednesday, March 20, 2:30pm
Arrays CSE 351 Spring 2017 Instructor: Ruth Anderson
Roadmap C: Java: Assembly language: OS: Machine code: Computer system:
Section 2: Integer & Floating Point Numbers
Today How’s Lab 3 going? HW 3 will be out today
CSE351: Memory, Data, & Addressing I CSE 351 Spring 2017
Virtual Memory I CSE 351 Autumn 2017
x86 Programming I CSE 351 Autumn 2016
The Hardware/Software Interface CSE351 Winter 2013
Switch & Procedures & The Stack I CSE 351 Winter 2017
Roadmap C: Java: Assembly language: OS: Machine code: Computer system:
CSE351: Memory and data
Announcements VM on the website! Speedometer!
x86-64 Programming III & The Stack CSE 351 Winter 2018
Java and C I CSE 351 Autumn 2016 Instructor: Justin Hsia
Data III & Integers I CSE 351 Autumn 2016
Structs and Alignment CSE 351 Autumn 2016
Assembly Programming IV CSE 351 Spring 2017
x86-64 Programming III & The Stack CSE 351 Winter 2018
Procedures & The Stack I CSE 351 Autumn 2016
Arrays CSE 351 Winter
Feb 2 Announcements Arrays/Structs in C Lab 2? HW2 released
Data III & Integers I CSE 351 Winter 2017
Roadmap C: Java: Assembly language: OS: Machine code: Computer system:
Jan 12 How’s Lab 1 going? Announcements
Roadmap C: Java: Assembly language: OS: Machine code: Computer system:
x86-64 Programming III & The Stack CSE 351 Autumn 2017
Structs and Alignment CSE 410 Winter 2017
Memory Allocation I CSE 351 Winter 2018
Memory Allocation I CSE 351 Winter 2018
Java and C CSE 351 Summer 2018 Instructor: Justin Hsia
Caches I CSE 351 Winter 2018 Instructor: Mark Wyse
Java and C CSE 351 Winter 2018 Instructor: Mark Wyse
Arrays CSE 351 Winter 2018 Instructor: Mark Wyse Teaching Assistants:
Roadmap C: Java: Assembly language: OS: Machine code: Computer system:
Caches I CSE 351 Winter 2018 Instructor: Mark Wyse
Structs & Alignment CSE 351 Autumn 2018
Executables & Arrays CSE 351 Autumn 2018
Java and C CSE 351 Autumn 2018 Instructor: Teaching Assistants:
Data III & Integers I CSE 351 Winter 2018
Data III & Integers I CSE 351 Winter 2018
Floating Point II, x86-64 Intro CSE 351 Autumn 2018
Java and C I CSE 351 Spring 2017 Instructor: Ruth Anderson
Caches I CSE 351 Autumn 2018 Instructors: Max Willsey Luis Ceze
Floating Point II, x86-64 Intro CSE 351 Autumn 2017
Java and C II CSE 351 Spring 2017 Instructor: Ruth Anderson
Memory Bugs, Java and C CSE 351 Winter 2019
Lecture 2: Bits, Bytes, Ints
Memory Allocation I CSE 351 Autumn 2018
Assembly Programming I CSE 351 Spring 2017
Presentation transcript:

Roadmap C: Java: Assembly language: OS: Machine code: Computer system: Memory & data Integers & floats Machine code & C x86 assembly Procedures & stacks Arrays & structs Memory & caches Processes Virtual memory Memory allocation Java vs. C C: Java: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Car c = new Car(); c.setMiles(100); c.setGals(17); float mpg = c.getMPG(); Assembly language: get_mpg: pushq %rbp movq %rsp, %rbp ... popq %rbp ret OS: Machine code: 0111010000011000 100011010000010000000010 1000100111000010 110000011111101000011111 Computer system: Encoding

Section 2: Integer & Floating Point Numbers Representation of integers: unsigned and signed Unsigned and signed integers in C Arithmetic and shifting Sign extension Background: fractional binary numbers IEEE floating-point standard Floating-point operations and rounding Floating-point in C Encoding

But before we get to integers…. How about encoding a standard deck of playing cards? 52 cards in 4 suits How do we encode suits, face cards? What operations do we want to make easy to implement? Which is the higher value card? Are they the same suit? Encoding

Two possible representations 52 cards – 52 bits with bit corresponding to card set to 1 “One-hot” encoding Drawbacks: Hard to compare values and suits Large number of bits required 4 bits for suit, 13 bits for card value – 17 bits with two set to 1 “Two-hot” encoding Easier to compare suits and values Still an excessive number of bits low-order 52 bits of 64-bit word Encoding

Two better representations Binary encoding of all 52 cards – only 6 bits needed Fits in one byte Smaller than one-hot or two-hot encoding, but how can we make value and suit comparisons easier? Binary encoding of suit (2 bits) and value (4 bits) separately Also fits in one byte, and easy to do comparisons low-order 6 bits of a byte suit value Encoding

Some basic operations Checking if two cards have the same suit: #define SUIT_MASK 0x30 char array[5]; // represents a 5 card hand char card1, card2; // two cards to compare card1 = array[0]; card2 = array[1]; ... if sameSuitP(card1, card2) { bool sameSuitP(char card1, char card2) { return (! (card1 & SUIT_MASK) ^ (card2 & SUIT_MASK)); //return (card1 & SUIT_MASK) == (card2 & SUIT_MASK); } SUIT_MASK = 0x30; 1 1 suit value Encoding

Some basic operations Comparing the values of two cards: #define SUIT_MASK 0x30 #define VALUE_MASK 0x0F char array[5]; // represents a 5 card hand char card1, card2; // two cards to compare card1 = array[0]; card2 = array[1]; ... if greaterValue(card1, card2) { bool greaterValue(char card1, char card2) { return ((unsigned int)(card1 & VALUE_MASK) > (unsigned int)(card2 & VALUE_MASK)); } VALUE_MASK = 0x0F; 1 1 1 1 suit value Encoding