CISC 360 Midterm Exam - Review Alignment

Size: px
Start display at page:

Download "CISC 360 Midterm Exam - Review Alignment"

Transcription

1 CISC 360 Midterm Exam - Review Alignment Michela Taufer October 14, 2008 Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, CS:APP 2003

2 Alignment Aligned Data Primitive data type requires K bytes Address must be multiple of K Required on some machines; advised on IA32 treated differently by Linux and Windows! Motivation for Aligning Data Memory accessed by (aligned) double or quad-words Inefficient to load or store datum that spans quad word boundaries Virtual memory very tricky when datum spans 2 pages Compiler Inserts gaps in structure to ensure correct alignment of fields 2 CISCʼFa08

3 Specific Cases of Alignment Size of Primitive Data Type: 1 byte (e.g., char) no restrictions on address 2 bytes (e.g., short) lowest 1 bit of address must be bytes (e.g., int, float, char *, etc.) lowest 2 bits of address must be bytes (e.g., double) Windows (and most other OSʼs & instruction sets):» lowest 3 bits of address must be Linux:» lowest 2 bits of address must be 00 2» i.e., treated the same as a 4-byte primitive data type 12 bytes (long double) Linux:» lowest 2 bits of address must be 00 2» i.e., treated the same as a 4-byte primitive data type 3 CISCʼFa08

4 Satisfying Alignment with Structures Offsets Within Structure Must satisfy elementʼs alignment requirement Overall Structure Placement Each structure has alignment requirement K Largest alignment of any element Initial address & structure length must be multiples of K struct S1 { char c; int i[2]; double v; } *p; Example (under Windows): K = 8, due to double element c i[0] i[1] v p+0 p+4 p+8 p+16 p+24 Multiple of 4 Multiple of 8 Multiple of 8 Multiple of 8 4 CISCʼFa08

5 Linux vs. Windows Windows (including Cygwin): K = 8, due to double element struct S1 { char c; int i[2]; double v; } *p; Linux: c i[0] i[1] v p+0 p+4 p+8 p+16 p+24 Multiple of 4 Multiple of 8 Multiple of 8 Multiple of 8 K = 4; double treated like a 4-byte data type c i[0] i[1] p+0 p+4 p+8 Multiple of 4 Multiple of 4 Multiple of 4 5 CISCʼFa08 v p+12 p+20 Multiple of 4

6 Overall Alignment Requirement struct S2 { double x; int i[2]; char c; } *p; p must be multiple of: 8 for Windows 4 for Linux x i[0] i[1] c p+0 p+8 p+12 p+16 Windows: p+24 Linux: p+20 struct S3 { float x[2]; int i[2]; char c; p must be multiple of 4 (in either OS) } *p; x[0] x[1] i[0] i[1] p+0 p+4 p+8 p+12 p+16 p+20 c 6 CISCʼFa08

7 Ordering Elements Within Structure struct S4 { char c1; double v; char c2; int i; } *p; 10 bytes wasted space in Windows c1 v p+0 p+8 p+16 p+20 p+24 c2 i struct S5 { double v; char c1; char c2; int i; } *p; 2 bytes wasted space v c1 c2 p+0 p+8 p+12 p+16 i 7 CISCʼFa08

8 Arrays of Structures Principle Allocated by repeating allocation for array type In general, may nest arrays & structures to arbitrary depth struct S6 { short i; float v; short j; } a[10]; a[1].i a[1].v a[1].j a+12 a+16 a+20 a+24 a[0] a[1] a[2] a+0 a+12 a+24 a+36 8 CISCʼFa08

9 Union Allocation Principles Overlay union elements Allocate according to largest element Can only use one field at a time struct S1 { char c; int i[2]; double v; } *sp; union U1 { char c; int i[2]; double v; } *up; (Windows alignment) c i[0] i[1] v up+0 up+4 up+8 c i[0] i[1] v sp+0 sp+4 sp+8 sp+16 sp+24 9 CISCʼFa08

10 CISC 360 Computer Architecture Logic Design Michela Taufer October 14, 2008 Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, CS:APP 2003

11 Overview of Logic Design Fundamental Hardware Requirements Communication How to get values from one place to another Computation Storage Bits are Our Friends Everything expressed in terms of values 0 and 1 Communication Low or high voltage on wire Computation Compute Boolean functions Storage Store bits of information 11 CISCʼFa08

12 Digital Signals Voltage Time Use voltage thresholds to extract discrete values from continuous signal Simplest version: 1-bit signal Either high range (1) or low range (0) With guard range between them Not strongly affected by noise or low quality circuit elements Can make circuits simple, small, and fast 12 CISCʼFa08

13 Computing with Logic Gates a b And Or Not out a b out a out out = a && b out = a b out =!a Outputs are Boolean functions of inputs Respond continuously to changes in inputs With some, small delay Rising Delay Falling Delay a && b b Voltage a Time 13 CISCʼFa08

14 Combinational Circuits Acyclic Network Primary Inputs Primary Outputs Acyclic Network of Logic Gates Continously responds to changes on primary inputs Primary outputs become (after some delay) Boolean functions of primary inputs 14 CISCʼFa08

15 Bit Equality a Bit equal HCL Expression eq bool eq = (a&&b) (!a&&!b) b Generate 1 if a and b are equal Hardware Control Language (HCL) Very simple hardware description language Boolean operations have syntax similar to C logical operations Weʼll use it to describe control logic for processors 15 CISCʼFa08

16 Word Equality Word-Level Representation b 31 a 31 b 30 a 30 Bit equal Bit equal eq 31 eq 30 B A = Eq HCL Representation Eq bool Eq = (A == B) b 1 a 1 b 0 a 0 Bit equal Bit equal eq 1 eq 0 32-bit word size HCL representation Equality operation Generates Boolean value 16 CISCʼFa08

17 Bit-Level Multiplexor s Bit MUX HCL Expression b a out bool out = (s&&a) (!s&&b) Control signal s Data signals a and b Output a when s=1, b when s=0 17 CISCʼFa08

18 Word Multiplexor s Word-Level Representation s b 31 out 31 B A MUX Out a 31 b 30 a 30 out 30 HCL Representation int Out = [ s : A; 1 : B; ]; b 0 a 0 out 0 Select input word A or B depending on control signal s HCL representation Case expression Series of test : value pairs Output value for first successful test 18 CISCʼFa08

19 HCL Word-Level Examples Minimum of 3 Words C B A MIN3 Min3 int Min3 = [ A < B && A < C : A; B < A && B < C : B; 1 : C; ]; Find minimum of three input words HCL case expression Final case guarantees match 4-Way Multiplexor s1 s0 D0 D1 D2 D3 MUX4 Out4 int Out4 = [!s1&&!s0: D0;!s1 : D1;!s0 : D2; 1 : D3; ]; Select one of 4 inputs based on two control bits HCL case expression Simplify tests by assuming sequential matching 19 CISCʼFa08

20 Arithmetic Logic Unit Y X A B A L U OF ZF CF X + Y Y X A B A L U OF ZF CF X - Y Y X A B A L U OF ZF CF X & Y Y X A B A L U OF ZF CF X ^ Y Combinational logic Continuously responding to inputs Control signal selects function computed Corresponding to 4 arithmetic/logical operations in Y86 Also computes values for condition codes 20 CISCʼFa08

21 Registers Structure i 7 D C Q+ o 7 i 6 D C Q+ o 6 i 5 D C Q+ o 5 i 4 i 3 D C D C Q+ Q+ o 4 o 3 I O i 2 i 1 D C D C Q+ Q+ o 2 o 1 Clock i 0 D C Q+ o 0 Clock Stores word of data Different from program registers seen in assembly code Collection of edge-triggered latches Loads input on rising edge of clock 21 CISCʼFa08

22 Register Operation State = x State = y Input = y x Output = x Rising clock y Output = y Stores data bits For most of time acts as barrier between input and output As clock rises, loads input 22 CISCʼFa08

23 State Machine Example In Comb. Logic 0 A L U 0 1 MUX Out Accumulator circuit Load or accumulate on each cycle Load Clock Clock Load In Out x 0 x 1 x 2 x 3 x 4 x 5 x 0 x 0 +x 1 x 0 +x 1 +x 2 x 3 x 3 +x 4 x 3 +x 4 +x 5 23 CISCʼFa08

24 Random-Access Memory vala Read ports srca valb A Register file W valw dstw Write port srcb B Stores multiple words of memory Address input specifies which word to read or write Register file Holds values of program registers %eax, %esp, etc. Register identifier serves as address» ID 8 implies no read or write performed Multiple Ports Clock Can read and/or write multiple words in one cycle» Each has separate address and data input/output 24 CISCʼFa08

25 Register File Timing x vala srca valb srcb A B 2 x Register file Reading Like combinational logic Output data generated based on input address After some delay 2 Writing Like register Update only as clock rises 2 x Register file W valw dstw y 2 Rising clock 2 y Register file W valw dstw Clock Clock 25 CISCʼFa08

26 Hardware Control Language Very simple hardware description language Can only express limited aspects of hardware operation Parts we want to explore and modify Data Types bool: Boolean a, b, c, int: words A, B, C, Statements Does not specify word size---bytes, 32-bit words, bool a = bool-expr ; int A = int-expr ; 26 CISCʼFa08

27 HCL Operations Classify by type of value returned Boolean Expressions Logic Operations a && b, a b,!a Word Comparisons A == B, A!= B, A < B, A <= B, A >= B, A > B Set Membership A in { B, C, D } Word Expressions» Same as A == B A == C A == D Case expressions [ a : A; b : B; c : C ] Evaluate test expressions a, b, c, in sequence Return word expression A, B, C, for first successful test 27 CISCʼFa08

28 Summary Computation Performed by combinational logic Computes Boolean functions Continuously reacts to input changes Storage Registers Hold single words Loaded as clock rises Random-access memories Hold multiple words Possible multiple read or write ports Read word when address input changes Write word as clock rises 28 CISCʼFa08

29 Deadlines 7 Oct 14 Lec11 Logic Design Lab 2 7 Oct 16 Lec12 Sequential Implementation 8 Oct 21 Lec13 Pipelined Implementation I 8 Oct 23 Lec14 Pipelined Implementation II 8 (*) Oct 24 Exercises in class in preparation to exam 9 Oct 28 Lec15 Computer Architecture Wrapup 9 Oct 30 Exam II 10 Nov 4 No class 10 Nov 6 Lec16 Program Optimization I 5 4 Lab 3 29 CISCʼFa08

CS:APP Chapter 4 Computer Architecture Logic Design Randal E. Bryant Carnegie Mellon University

CS:APP Chapter 4 Computer Architecture Logic Design Randal E. Bryant Carnegie Mellon University S:PP hapter 4 omputer rchitecture Logic esign Randal E. Bryant arnegie Mellon University http://csapp.cs.cmu.edu S:PP Overview of Logic esign Fundamental Hardware Requirements ommunication How to get values

More information

CS429: Computer Organization and Architecture

CS429: Computer Organization and Architecture CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: January 2, 2018 at 11:23 CS429 Slideset 5: 1 Topics of this Slideset

More information

Topics of this Slideset. CS429: Computer Organization and Architecture. Digital Signals. Truth Tables. Logic Design

Topics of this Slideset. CS429: Computer Organization and Architecture. Digital Signals. Truth Tables. Logic Design Topics of this Slideset CS429: Computer Organization and rchitecture Dr. Bill Young Department of Computer Science University of Texas at ustin Last updated: July 5, 2018 at 11:55 To execute a program

More information

More in-class activities / questions

More in-class activities / questions Reading Responses 6 Yes, 1 No More often, reiew questions? Current Lab Format Yes: 6 yes, 3 No Maybe a 5-min introduction to help get started? More in-class actiities / questions Yes: 5, No: 1 Long Slides

More information

Computer Science 104:! Y86 & Single Cycle Processor Design!

Computer Science 104:! Y86 & Single Cycle Processor Design! Computer Science 104: Y86 & Single Cycle Processor Design Alvin R. Lebeck Slides based on those from Randy Bryant 1 CS:APP Administrative Homework #4 My office hours today 11:30-12:30 Reading: text 4.3

More information

CS241 Computer Organization Spring Data Alignment

CS241 Computer Organization Spring Data Alignment CS241 Computer Organization Spring 2015 Data Alignment 3-26 2015 Outline! Data Alignment! C: pointers to functions! Memory Layout Read: CS:APP2 Chapter 3, sections 3.8-3.9 Quiz next Thursday, April 2nd

More information

Basic Data Types. Lecture 6A Machine-Level Programming IV: Structured Data. Array Allocation. Array Access Basic Principle

Basic Data Types. Lecture 6A Machine-Level Programming IV: Structured Data. Array Allocation. Array Access Basic Principle Lecture 6 Machine-Level Programming IV: Structured Data Topics rrays Structs Unions Basic Data Types Integral Stored & operated on in general registers Signed vs. unsigned depends on instructions used

More information

CISC Fall 2009

CISC Fall 2009 Michela Taufer October 20, 2009 Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, 2003 Y86 Instruction Set Byte 0 1 2 3 4 5 nop 0 0

More information

Assembly IV: Complex Data Types. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Assembly IV: Complex Data Types. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University ssembly IV: Complex Data Types Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Basic Data Types Integer Stored & operated on in general registers

More information

MACHINE-LEVEL PROGRAMMING IV: Computer Organization and Architecture

MACHINE-LEVEL PROGRAMMING IV: Computer Organization and Architecture MACHINE-LEVEL PROGRAMMING IV: DATA CS 045 Computer Organization and Architecture Prof. Donald J. Patterson Adapted from Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

More information

CS429: Computer Organization and Architecture

CS429: Computer Organization and Architecture CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: March 5, 2018 at 05:33 CS429 Slideset 11: 1 Alignment CS429 Slideset

More information

CS:APP Chapter 4 Computer Architecture Sequential Implementation

CS:APP Chapter 4 Computer Architecture Sequential Implementation CS:APP Chapter 4 Computer Architecture Sequential Implementation Randal E. Bryant Carnegie Mellon University CS:APP Y86 Instruction Set Byte ra rb ra rb V rb rb V ra D rb ra rb D D rb ra ra rb D ra rb

More information

Instruction Set Architecture

Instruction Set Architecture CISC 360 Instruction Set Architecture Michela Taufer October 9, 2008 Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, 2003 Chapter

More information

CISC 360 Instruction Set Architecture

CISC 360 Instruction Set Architecture CISC 360 Instruction Set Architecture Michela Taufer October 9, 2008 Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, 2003 Chapter

More information

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

Roadmap. Java: Assembly language: OS: Machine code: Computer system: Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp

More information

CS:APP Chapter 4 Computer Architecture Sequential Implementation

CS:APP Chapter 4 Computer Architecture Sequential Implementation CS:APP Chapter 4 Computer Architecture Sequential Implementation Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP Y86 Instruction Set Byte 0 1 2 3 4 5 nop 0 0 halt 1 0 rrmovl

More information

Computer Systems CEN591(502) Fall 2011

Computer Systems CEN591(502) Fall 2011 Computer Systems CEN591(502) Fall 2011 Sandeep K. S. Gupta Arizona State University 9 th lecture Machine-Level Programming (4) (Slides adapted from CSAPP) Announcements Potentially Makeup Classes on Sat

More information

cmovxx ra, rb 2 fn ra rb irmovq V, rb 3 0 F rb V rmmovq ra, D(rB) 4 0 ra rb D mrmovq D(rB), ra 5 0 ra rb D OPq ra, rb 6 fn ra rb jxx Dest 7 fn Dest

cmovxx ra, rb 2 fn ra rb irmovq V, rb 3 0 F rb V rmmovq ra, D(rB) 4 0 ra rb D mrmovq D(rB), ra 5 0 ra rb D OPq ra, rb 6 fn ra rb jxx Dest 7 fn Dest Computer Architecture: Y86-64 Sequential Implementation CSci 2021: Machine Architecture and Organization October 31st, 2018 Your instructor: Stephen McCamant Based on slides originally by: Randy Bryant

More information

cmovxx ra, rb 2 fn ra rb irmovq V, rb 3 0 F rb V rmmovq ra, D(rB) 4 0 ra rb D mrmovq D(rB), ra 5 0 ra rb D OPq ra, rb 6 fn ra rb jxx Dest 7 fn Dest

cmovxx ra, rb 2 fn ra rb irmovq V, rb 3 0 F rb V rmmovq ra, D(rB) 4 0 ra rb D mrmovq D(rB), ra 5 0 ra rb D OPq ra, rb 6 fn ra rb jxx Dest 7 fn Dest Computer Architecture: Y86-64 Sequential Implementation CSci 2021: Machine Architecture and Organization Lecture #19, March 4th, 2016 Your instructor: Stephen McCamant Based on slides originally by: Randy

More information

Computer Organization: A Programmer's Perspective

Computer Organization: A Programmer's Perspective A Programmer's Perspective Machine-Level Programming (4: Data Structures) Gal A. Kaminka galk@cs.biu.ac.il Today Arrays One-dimensional Multi-dimensional (nested) Multi-level Structures Allocation Access

More information

Structs and Alignment CSE 351 Spring

Structs and Alignment CSE 351 Spring Structs and Alignment CSE 351 Spring 2018 http://xkcd.com/1168/ Administrivia Homework 3 due Wednesday Lab 3 released, due next week Lab 2 and midterm will be graded this week [in that order] 2 Roadmap

More information

CISC: Stack-intensive procedure linkage. [Early] RISC: Register-intensive procedure linkage.

CISC: Stack-intensive procedure linkage. [Early] RISC: Register-intensive procedure linkage. CISC: Stack-intensive procedure linkage. The stack is used for procedure arguments and return addresses. [Early] RISC: Register-intensive procedure linkage. Registers are used for procedure arguments and

More information

CS:APP Chapter 4 Computer Architecture Sequential Implementation

CS:APP Chapter 4 Computer Architecture Sequential Implementation CS:APP Chapter 4 Computer Architecture Sequential Implementation Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP Y86 Instruction Set Byte 0 1 2 3 4 5 nop 0 0 halt 1 0 rrmovl

More information

Processor Architecture

Processor Architecture Processor Architecture God created the integers, all else is the work of man Leopold Kronecker (He believed in the reduction of all mathematics to arguments involving only the integers and a finite number

More information

Giving credit where credit is due

Giving credit where credit is due CSCE 230J Computer Organization Processor Architecture III: Sequential Implementation Dr. Steve Goddard goddard@cse.unl.edu http://cse.unl.edu/~goddard/courses/csce230j Giving credit where credit is due

More information

Machine-Level Prog. IV - Structured Data

Machine-Level Prog. IV - Structured Data Machine-Level Prog. IV - Structured Data Today! rrays! Structures! Unions Next time! Buffer overflow, x86-64 Fabián E. Bustamante, 2007 Basic data types! Integral Stored & operated on in general registers

More information

Computer Organization Chapter 4. Prof. Qi Tian Fall 2013

Computer Organization Chapter 4. Prof. Qi Tian Fall 2013 Computer Organization Chapter 4 Prof. Qi Tian Fall 2013 1 Topics Dec. 6 (Friday) Final Exam Review Record Check Dec. 4 (Wednesday) 5 variable Karnaugh Map Quiz 5 Dec. 2 (Monday) 3, 4 variables Karnaugh

More information

Assembly IV: Complex Data Types. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Assembly IV: Complex Data Types. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University ssembly IV: Complex Data Types Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Basic Data Types Integer Stored & operated on in general registers

More information

Chapter 4! Processor Architecture!!

Chapter 4! Processor Architecture!! Chapter 4! Processor Architecture!! Sequential Implementation! Instructor: Dr. Hyunyoung Lee! Texas A&M University! Based on slides provided by Randal E. Bryant, CMU Topics Covered! Hardware Control Language

More information

Assembly IV: Complex Data Types

Assembly IV: Complex Data Types ssembly IV: Complex Data Types Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE2030: Introduction to Computer Systems, Spring 2018, Jinkyu Jeong

More information

Where Have We Been? Logic Design in HCL. Assembly Language Instruction Set Architecture (Y86) Finite State Machines

Where Have We Been? Logic Design in HCL. Assembly Language Instruction Set Architecture (Y86) Finite State Machines Where Have We Been? Assembly Language Instruction Set Architecture (Y86) Finite State Machines States and Transitions Events Where Are We Going? Tracing Instructions at the Register Level Build a CPU!

More information

Computer Science 104:! Y86 & Single Cycle Processor Design!

Computer Science 104:! Y86 & Single Cycle Processor Design! Computer Science 104: Y86 & Single Cycle Processor Design Alvin R. Lebeck Slides based on those from Randy Bryant CS:APP Administrative HW #4 Due tomorrow tonight HW #5 up soon ing: 4.1-4.3 Today Review

More information

Sequential Implementation

Sequential Implementation CS:APP Chapter 4 Computer Architecture Sequential Implementation Randal E. Bryant adapted by Jason Fritts http://csapp.cs.cmu.edu CS:APP2e Hardware Architecture - using Y86 ISA For learning aspects of

More information

God created the integers, all else is the work of man Leopold Kronecker

God created the integers, all else is the work of man Leopold Kronecker Sequential Hardware God created the integers, all else is the work of man Leopold Kronecker (He believed in the reduction of all mathematics to arguments involving only the integers and a finite number

More information

Foundations of Computer Systems

Foundations of Computer Systems 18-600 Foundations of Computer Systems Lecture 7: Processor Architecture & Design John P. Shen & Gregory Kesden September 20, 2017 Lecture #7 Processor Architecture & Design Lecture #8 Pipelined Processor

More information

L14: Structs and Alignment. Structs and Alignment. CSE 351 Spring Instructor: Ruth Anderson

L14: Structs and Alignment. Structs and Alignment. CSE 351 Spring Instructor: Ruth Anderson Structs and Alignment CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Lab 2 due TONIGHT

More information

Processor Architecture II! Sequential! Implementation!

Processor Architecture II! Sequential! Implementation! Processor Architecture II! Sequential! Implementation! Lecture 6, April 14 th 2011 Alexandre David Slides by Randal E. Bryant! Carnegie Mellon University! Y86 Instruction Set! Byte! 0 1 2 3 4 5 nop 0 0

More information

CS:APP Chapter 4! Computer Architecture! Sequential! Implementation!

CS:APP Chapter 4! Computer Architecture! Sequential! Implementation! CS:APP Chapter 4! Computer Architecture! Sequential! Implementation! Randal E. Bryant! Carnegie Mellon University! http://csapp.cs.cmu.edu CS:APP2e! Y86 Instruction Set #1! Byte! 0 1 2 3 4 5 halt 0 0 nop

More information

Structs & Alignment. CSE 351 Autumn Instructor: Justin Hsia

Structs & Alignment. CSE 351 Autumn Instructor: Justin Hsia Structs & Alignment CSE 351 Autumn 2018 Instructor: Justin Hsia Teaching Assistants: Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson Sophie

More information

Computer Science 104:! Y86 & Single Cycle Processor Design!

Computer Science 104:! Y86 & Single Cycle Processor Design! Computer Science 104:! Y86 & Single Cycle Processor Design! Alvin R. Lebeck! Slides based on those from Randy Bryant 1! CS:APP! CS:APP! Administrative! 2! CS:APP! Instruction Set Architecture! Application!

More information

Arrays and Structs. CSE 351 Summer Instructor: Justin Hsia. Teaching Assistants: Josie Lee Natalie Andreeva Teagan Horkan.

Arrays and Structs. CSE 351 Summer Instructor: Justin Hsia. Teaching Assistants: Josie Lee Natalie Andreeva Teagan Horkan. rrays and Structs CSE 351 Summer 2018 Instructor: Justin Hsia Teaching ssistants: Josie Lee Natalie ndreeva Teagan Horkan http://xkcd.com/1270/ dministrivia Lab 2 due tonight Homework 3 due next Monday

More information

u Arrays One-dimensional Multi-dimensional (nested) Multi-level u Structures Allocation Access Alignment u Floating Point

u Arrays One-dimensional Multi-dimensional (nested) Multi-level u Structures Allocation Access Alignment u Floating Point u Arrays One-dimensional Multi-dimensional (nested) Multi-level u Structures Allocation Access Alignment u Floating Point u Basic Principle T A[L]; Array of data type T and length L Contiguously allocated

More information

Michela Taufer CS:APP

Michela Taufer CS:APP ichela Taufer CS:APP Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and. O'Hallaron, Prentice Hall, 2003 Overview 2 CISC 360 Faʼ08 Pipeline Stages W_icode, W_val W

More information

Systems I. Logic Design I. Topics Digital logic Logic gates Simple combinational logic circuits

Systems I. Logic Design I. Topics Digital logic Logic gates Simple combinational logic circuits Systems I Logic Design I Topics Digitl logic Logic gtes Simple comintionl logic circuits Simple C sttement.. C = + ; Wht pieces of hrdwre do you think you might need? Storge - for vlues,, C Computtion

More information

Machine-level Programs Data

Machine-level Programs Data Computer Systems Machine-level Programs Data Han, Hwansoo rray llocation Basic Principle T [L]; rray of data type T and length L Contiguously allocated region of L * sizeof(t) bytes in memory char string[12];

More information

Giving credit where credit is due

Giving credit where credit is due JDEP 284H Foundations of Computer Systems Processor rchitecture III: Sequential Implementation Dr. Steve Goddard goddard@cse.unl.edu Giving credit where credit is due Most of slides for this lecture are

More information

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam

Assembly Language. Lecture 2 - x86 Processor Architecture. Ahmed Sallam Assembly Language Lecture 2 - x86 Processor Architecture Ahmed Sallam Introduction to the course Outcomes of Lecture 1 Always check the course website Don t forget the deadline rule!! Motivations for studying

More information

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19 Data Storage Geoffrey Brown Bryce Himebaugh Indiana University August 9, 2016 Geoffrey Brown, Bryce Himebaugh 2015 August 9, 2016 1 / 19 Outline Bits, Bytes, Words Word Size Byte Addressable Memory Byte

More information

Memory Organization and Addressing

Memory Organization and Addressing Memory Organization and essing CSCI 224 / ECE 317: Computer Architecture Instructor: Prof. Jason Fritts Slides adapted from Bryant & O Hallaron s slides 1 Data Representation in Memory Memory organization

More information

Background: Sequential processor design. Computer Architecture and Systems Programming , Herbstsemester 2013 Timothy Roscoe

Background: Sequential processor design. Computer Architecture and Systems Programming , Herbstsemester 2013 Timothy Roscoe Background: Sequential processor design Computer Architecture and Systems Programming 252 0061 00, Herbstsemester 2013 Timothy Roscoe Overview Y86 instruction set architecture Processor state Instruction

More information

CPSC 213. Introduction to Computer Systems. Introduction. Unit 0

CPSC 213. Introduction to Computer Systems. Introduction. Unit 0 CPSC 213 Introduction to Computer Systems Unit Introduction 1 Overview of the course Hardware context of a single executing program hardware context is CPU and Main Memory develop CPU architecture to implement

More information

Data Structures in Memory!

Data Structures in Memory! Data Structures in Memory! Arrays One- dimensional Mul/- dimensional (nested) Mul/- level Structs Alignment Unions 1 What is memory again? 2 Data Structures in Assembly Arrays? Strings? Structs? 3 Array

More information

Assembly Language. Lecture 2 x86 Processor Architecture

Assembly Language. Lecture 2 x86 Processor Architecture Assembly Language Lecture 2 x86 Processor Architecture Ahmed Sallam Slides based on original lecture slides by Dr. Mahmoud Elgayyar Introduction to the course Outcomes of Lecture 1 Always check the course

More information

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 2, 2016

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 2, 2016 CS 31: Intro to Systems Digital Logic Kevin Webb Swarthmore College February 2, 2016 Reading Quiz Today Hardware basics Machine memory models Digital signals Logic gates Circuits: Borrow some paper if

More information

System Programming CISC 360. Floating Point September 16, 2008

System Programming CISC 360. Floating Point September 16, 2008 System Programming CISC 360 Floating Point September 16, 2008 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Powerpoint Lecture Notes for Computer Systems:

More information

Machine Level Programming: Arrays, Structures and More

Machine Level Programming: Arrays, Structures and More Machine Level Programming: rrays, Structures and More Computer Systems Organization (Spring 2016) CSCI-U 201, Section 2 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O

More information

Machine-Level Programming IV: Structured Data

Machine-Level Programming IV: Structured Data Machine-Level Programming IV: Structured Data Topics Arrays Structs Unions Basic Data Types Integral 2 Stored & operated on in general registers Signed vs. unsigned depends on instructions used Intel GAS

More information

CS 31: Intro to Systems Arrays, Structs, Strings, and Pointers. Kevin Webb Swarthmore College March 1, 2016

CS 31: Intro to Systems Arrays, Structs, Strings, and Pointers. Kevin Webb Swarthmore College March 1, 2016 CS 31: Intro to Systems Arrays, Structs, Strings, and Pointers Kevin Webb Swarthmore College March 1, 2016 Overview Accessing things via an offset Arrays, Structs, Unions How complex structures are stored

More information

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

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition 1 Machine-Level Programming IV: Data 15-213/18-213/14-513/15-513: Introduction to Computer Systems 8 th Lecture, September 20, 2018 2 Today Arrays One-dimensional Multi-dimensional (nested) Multi-level

More information

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 3, 2015

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 3, 2015 CS 31: Intro to Systems Digital Logic Kevin Webb Swarthmore College February 3, 2015 Reading Quiz Today Hardware basics Machine memory models Digital signals Logic gates Circuits: Borrow some paper if

More information

ENCM 369 Winter 2019 Lab 6 for the Week of February 25

ENCM 369 Winter 2019 Lab 6 for the Week of February 25 page of ENCM 369 Winter 29 Lab 6 for the Week of February 25 Steve Norman Department of Electrical & Computer Engineering University of Calgary February 29 Lab instructions and other documents for ENCM

More information

EE 4755 Digital Design Using Hardware Description Languages

EE 4755 Digital Design Using Hardware Description Languages EE 4755 Digital Design Using Hardware Description Languages Midterm Exam Review When / Where Monday, 16 October 2017, 9:30-10:20 CDT 225 Tureaud Hall (Here) Conditions Closed Book, Closed Notes Bring one

More information

Overview. CS429: Computer Organization and Architecture. Y86 Instruction Set. Building Blocks

Overview. CS429: Computer Organization and Architecture. Y86 Instruction Set. Building Blocks Overview CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: March 15, 2018 at 10:54 How do we build a digital computer?

More information

Complex Instruction Set Computer (CISC)

Complex Instruction Set Computer (CISC) Introduction ti to IA-32 IA-32 Processors Evolutionary design Starting in 1978 with 886 Added more features as time goes on Still support old features, although obsolete Totally dominate computer market

More information

Structs and Alignment

Structs and Alignment Structs and Alignment CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun

More information

CSC 252: Computer Organization Spring 2018: Lecture 9

CSC 252: Computer Organization Spring 2018: Lecture 9 CSC 252: Computer Organization Spring 2018: Lecture 9 Instructor: Yuhao Zhu Department of Computer Science University of Rochester Action Items: Assignment 2 is due tomorrow, midnight Assignment 3 is out

More information

CS 261 Fall Mike Lam, Professor. Combinational Circuits

CS 261 Fall Mike Lam, Professor. Combinational Circuits CS 261 Fall 2017 Mike Lam, Professor Combinational Circuits The final frontier Java programs running on Java VM C programs compiled on Linux Assembly / machine code on CPU + memory??? Switches and electric

More information

Processor Architecture I. Alexandre David

Processor Architecture I. Alexandre David Processor Architecture I Alexandre David Overview n Introduction: from transistors to gates. n and from gates to circuits. n 4.1 n 4.2 n Micro+macro code. 12-04-2011 CART - Aalborg University 2 Evolution

More information

Cache Memory and Performance

Cache Memory and Performance Cache Memory and Performance Cache Organization 1 Many of the following slides are taken with permission from Complete Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective (CS:APP)

More information

CISC 662 Graduate Computer Architecture Lecture 16 - Cache and virtual memory review

CISC 662 Graduate Computer Architecture Lecture 16 - Cache and virtual memory review CISC 662 Graduate Computer Architecture Lecture 6 - Cache and virtual memory review Michela Taufer http://www.cis.udel.edu/~taufer/teaching/cis662f07 Powerpoint Lecture Notes from John Hennessy and David

More information

CS 261 Fall Mike Lam, Professor. Logic Gates

CS 261 Fall Mike Lam, Professor. Logic Gates CS 261 Fall 2016 Mike Lam, Professor Logic Gates The final frontier Java programs running on Java VM C programs compiled on Linux Assembly / machine code on CPU + memory??? Switches and electric signals

More information

Computer Science 104:! Y86 & Single Cycle Processor Design!

Computer Science 104:! Y86 & Single Cycle Processor Design! Computer Science 104:! Y86 & Single Cycle Processor Design! Alvin R. Lebeck! Slides based on those from Randy Bryant CS:APP! Administrative! 2! CS:APP! Y86 Instruction Set! Byte! 0 1 2 3 4 5 nop 0 0 halt

More information

CS:APP Chapter 4 Computer Architecture Wrap-Up Randal E. Bryant Carnegie Mellon University

CS:APP Chapter 4 Computer Architecture Wrap-Up Randal E. Bryant Carnegie Mellon University CS:APP Chapter 4 Computer Architecture Wrap-Up Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP2e Overview Wrap-Up of PIPE Design Exceptional conditions Performance analysis Fetch

More information

Systems Architecture

Systems Architecture Systems Architecture Lecture 15: A Simple Implementation of MIPS Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some or all figures from Computer Organization and Design: The Hardware/Software

More information

Last Name Student Number. Last Name Student Number

Last Name Student Number. Last Name Student Number University of Toronto Faculty of Applied Science and Engineering Department of Electrical and Computer Engineering Midterm Examination ECE 241F - Digital Systems Wednesday October 13, 2004, 6:00pm [5]

More information

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006 C Compilation Model Comp-206 : Introduction to Software Systems Lecture 9 Alexandre Denault Computer Science McGill University Fall 2006 Midterm Date: Thursday, October 19th, 2006 Time: from 16h00 to 17h30

More information

CS 31: Intro to Systems ISAs and Assembly. Martin Gagné Swarthmore College February 7, 2017

CS 31: Intro to Systems ISAs and Assembly. Martin Gagné Swarthmore College February 7, 2017 CS 31: Intro to Systems ISAs and Assembly Martin Gagné Swarthmore College February 7, 2017 ANNOUNCEMENT All labs will meet in SCI 252 (the robot lab) tomorrow. Overview How to directly interact with hardware

More information

EECS 213 Fall 2007 Midterm Exam

EECS 213 Fall 2007 Midterm Exam Full Name: EECS 213 Fall 2007 Midterm Exam Instructions: Make sure that your exam is not missing any sheets, then write your full name on the front. Write your answers in the space provided below the problem.

More information

Course overview. Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18. with slides by Kip Irvine

Course overview. Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18. with slides by Kip Irvine Course overview Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18 with slides by Kip Irvine Logistics Meeting time: 9:10am-12:10pm, Monday Classroom: CSIE Room 102 Instructor: Yung-Yu

More information

Referencing Examples

Referencing Examples Referencing Examples zip_dig cmu; 1 5 2 1 3 16 20 24 28 32 36 zip_dig mit; 0 2 1 3 9 36 40 44 48 52 56 zip_dig nwu; 6 0 2 0 1 56 60 64 68 72 76 Code Does Not Do ny Bounds Checking! Reference ddress Value

More information

Credits and Disclaimers

Credits and Disclaimers Credits and Disclaimers 1 The examples and discussion in the following slides have been adapted from a variety of sources, including: Chapter 3 of Computer Systems 2 nd Edition by Bryant and O'Hallaron

More information

CSC 252: Computer Organization Spring 2018: Lecture 11

CSC 252: Computer Organization Spring 2018: Lecture 11 CSC 252: Computer Organization Spring 2018: Lecture 11 Instructor: Yuhao Zhu Department of Computer Science University of Rochester Action Items: Assignment 3 is due March 2, midnight Announcement Programming

More information

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA CISC 662 Graduate Computer Architecture Lecture 4 - ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,

More information

Sample Exam I PAC II ANSWERS

Sample Exam I PAC II ANSWERS Sample Exam I PAC II ANSWERS Please answer questions 1 and 2 on this paper and put all other answers in the blue book. 1. True/False. Please circle the correct response. a. T In the C and assembly calling

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c/su06 CS61C : Machine Structures Lecture #14: Combinational Logic, Gates, and State 2006-07-20 CS 61C L14 Combinational Logic (1) Andy Carle What are Machine Structures? Software

More information

CS:APP Chapter 4 Computer Architecture Wrap-Up Randal E. Bryant Carnegie Mellon University

CS:APP Chapter 4 Computer Architecture Wrap-Up Randal E. Bryant Carnegie Mellon University CS:APP Chapter 4 Computer Architecture Wrap-Up Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP Overview Wrap-Up of PIPE Design Performance analysis Fetch stage design Exceptional

More information

Introduction to Programming (Java) 2/12

Introduction to Programming (Java) 2/12 Introduction to Programming (Java) 2/12 Michal Krátký Department of Computer Science Technical University of Ostrava Introduction to Programming (Java) 2008/2009 c 2006 2008 Michal Krátký Introduction

More information

Introduction to IA-32. Jo, Heeseung

Introduction to IA-32. Jo, Heeseung Introduction to IA-32 Jo, Heeseung IA-32 Processors Evolutionary design Starting in 1978 with 8086 Added more features as time goes on Still support old features, although obsolete Totally dominate computer

More information

INTRODUCTION TO IA-32. Jo, Heeseung

INTRODUCTION TO IA-32. Jo, Heeseung INTRODUCTION TO IA-32 Jo, Heeseung IA-32 PROCESSORS Evolutionary design Starting in 1978 with 8086 Added more features as time goes on Still support old features, although obsolete Totally dominate computer

More information

Chapter 4. The Processor Designing the datapath

Chapter 4. The Processor Designing the datapath Chapter 4 The Processor Designing the datapath Introduction CPU performance determined by Instruction Count Clock Cycles per Instruction (CPI) and Cycle time Determined by Instruction Set Architecure (ISA)

More information

Hardware: Logical View

Hardware: Logical View Hardware: Logical View CPU Memory Bus Disks Net USB Etc. 1 Hardware: Physical View USB I/O controller Storage connections CPU Memory 2 Hardware: 351 View (version 0) instructions? Memory CPU data CPU executes

More information

Introduction to Computer Architecture. Meet your Colleagues. Course Theme CISC Michela Taufer September 4, 2008

Introduction to Computer Architecture. Meet your Colleagues. Course Theme CISC Michela Taufer September 4, 2008 CISC 360-010 Introduction to Computer Architecture Michela Taufer September 4, 2008 Topics: Course policies and overview Theme Five great realities of computer systems Powerpoint Lecture Notes for Computer

More information

CS:APP Guide to Y86 Processor Simulators

CS:APP Guide to Y86 Processor Simulators CS:APP Guide to Y86 Processor Simulators Randal E. Bryant David R. O Hallaron November 4, 2004 Copyright c 2002, R. E. Bryant, D. R. O Hallaron. All rights reserved. 1 This document describes the processor

More information

Graphics 2009/2010, period 1. Lecture 6: perspective projection

Graphics 2009/2010, period 1. Lecture 6: perspective projection Graphics 2009/2010, period 1 Lecture 6 Perspective projection Orthographic vs. perspective projection Introduction Projecting from arbitrary camera positions Orthographic projection and the canonical view

More information

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,...

We can study computer architectures by starting with the basic building blocks. Adders, decoders, multiplexors, flip-flops, registers,... COMPUTER ARCHITECTURE II: MICROPROCESSOR PROGRAMMING We can study computer architectures by starting with the basic building blocks Transistors and logic gates To build more complex circuits Adders, decoders,

More information

CSC258: Computer Organization. Memory Systems

CSC258: Computer Organization. Memory Systems CSC258: Computer Organization Memory Systems 1 Summer Independent Studies I m looking for a few students who will be working on campus this summer. In addition to the paid positions posted earlier, I have

More information

QUIZ How do we implement run-time constants and. compile-time constants inside classes?

QUIZ How do we implement run-time constants and. compile-time constants inside classes? QUIZ How do we implement run-time constants and compile-time constants inside classes? Compile-time constants in classes The static keyword inside a class means there s only one instance, regardless of

More information

CS241 Computer Organization Spring 2015 IA

CS241 Computer Organization Spring 2015 IA CS241 Computer Organization Spring 2015 IA-32 2-10 2015 Outline! Review HW#3 and Quiz#1! More on Assembly (IA32) move instruction (mov) memory address computation arithmetic & logic instructions (add,

More information

Lecture 1: Introduction to Digital Logic Design

Lecture 1: Introduction to Digital Logic Design Lecture 1: Introduction to Digital Logic Design CSE 140: Components and Design Techniques for Digital Systems Diba Mirza Dept. of Computer Science and Engineering University of California, San Diego 1

More information

Lectures 5-6: Introduction to C

Lectures 5-6: Introduction to C Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most

More information