About the Slides for Introduction to Computer Systems 15-213: Introduction to Computer Systems 0th Lecture, Sep. 1, 2015 Markus Püschel ETH Zurich (with.

Slides:



Advertisements
Similar presentations
Machine-Level Programming III: Procedures Feb. 8, 2000 Topics IA32 stack Stack-based languages Stack frames Register saving conventions Creating pointers.
Advertisements

Carnegie Mellon Today Program optimization  Optimization blocker: Memory aliasing  Out of order processing: Instruction level parallelism  Understanding.
Carnegie Mellon 1 Dynamic Memory Allocation: Basic Concepts : Introduction to Computer Systems 17 th Lecture, Oct. 21, 2010 Instructors: Randy Bryant.
Functions Functions and Parameters. History A function call needs to save the registers in use The called function will use the registers The registers.
University of Washington Last Time For loops  for loop → while loop → do-while loop → goto version  for loop → while loop → goto “jump to middle” version.
Machine-Level Programming III: Procedures Apr. 17, 2006 Topics IA32 stack discipline Register saving conventions Creating pointers to local variables CS213.
PC hardware and x86 3/3/08 Frans Kaashoek MIT
1 Function Calls Professor Jennifer Rexford COS 217 Reading: Chapter 4 of “Programming From the Ground Up” (available online from the course Web site)
Machine-Level Programming III: Procedures Sept. 17, 2007 IA32 stack discipline Register saving conventions Creating pointers to local variablesx86-64 Argument.
– 1 – , F’02 ICS05 Instructor: Peter A. Dinda TA: Bin Lin Recitation 4.
1 Homework Reading –PAL, pp , Machine Projects –Finish mp2warmup Questions? –Start mp2 as soon as possible Labs –Continue labs with your.
Machine-Level Programming III: Procedures Jan 30, 2003
Assembly תרגול 8 פונקציות והתקפת buffer.. Procedures (Functions) A procedure call involves passing both data and control from one part of the code to.
Machine-Level Programming III: Procedures Sept. 15, 2006 IA32 stack discipline Register saving conventions Creating pointers to local variablesx86-64 Argument.
September 22, 2014 Pengju (Jimmy) Jin Section E
Stack Activation Records Topics IA32 stack discipline Register saving conventions Creating pointers to local variables February 6, 2003 CSCE 212H Computer.
1 Carnegie Mellon Stacks : Introduction to Computer Systems Recitation 5: September 24, 2012 Joon-Sup Han Section F.
Lee CSCE 312 TAMU 1 Based on slides provided by Randy Bryant and Dave O’Hallaron Machine-Level Programming III: Switch Statements and IA32 Procedures Instructor:
Ithaca College Machine-Level Programming IV: IA32 Procedures Comp 21000: Introduction to Computer Systems & Assembly Lang Spring 2013 * Modified slides.
Machine-Level Programming III: Switch Statements and IA32 Procedures Seoul National University.
University of Washington Today More on procedures, stack etc. Lab 2 due today!  We hope it was fun! What is a stack?  And how about a stack frame? 1.
Code Generation Gülfem Savrun Yeniçeri CS 142 (b) 02/26/2013.
Fabián E. Bustamante, Spring 2007 Machine-Level Programming III - Procedures Today IA32 stack discipline Register saving conventions Creating pointers.
Recitation 2 – 2/11/02 Outline Stacks & Procedures Homogenous Data –Arrays –Nested Arrays Mengzhi Wang Office Hours: Thursday.
Recitation 2: Outline Assembly programming Using gdb L2 practice stuff Minglong Shao Office hours: Thursdays 5-6PM Wean Hall.
University of Washington Today Lab 2 due next Monday! Finish-up control flow Switch statements 1.
1 Carnegie Mellon Machine-Level Programming II: Arithmetic and Control Lecture, Feb. 28, 2012 These slides are from website which.
1 Machine-Level Programming IV: Control: loops Comp 21000: Introduction to Computer Organization & Systems March 2015 Systems book chapter 3* * Modified.
Machine-level Programming III: Procedures Topics –IA32 stack discipline –Register saving conventions –Creating pointers to local variables.
1 Procedure Call and Array. 2 Outline Data manipulation Control structure Suggested reading –Chap 3.7, 3.8.
Carnegie Mellon 1 Machine-Level Programming I: Basics Lecture, Feb. 21, 2013 These slides are from website which accompanies the.
1 Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Carnegie Mellon Machine-Level Programming II: Control Carnegie Mellon.
University of Amsterdam Computer Systems – the instruction set architecture Arnoud Visser 1 Computer Systems The instruction set architecture.
University of Washington x86 Programming II The Hardware/Software Interface CSE351 Winter 2013.
Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Carnegie Mellon Instructor: San Skulrattanakulchai Machine-Level Programming.
1 Assembly Language: Function Calls Jennifer Rexford.
Carnegie Mellon About the New Slides for Introduction to Computer Systems /18-243, spring 2009 Markus Püschel Electrical and Computer Engineering.
Recitation 2 – 2/11/02 Outline Stacks & Procedures Homogenous Data –Arrays –Nested Arrays Structured Data –struct s / union s –Arrays of structs.
IA32 Stack –Region of memory managed with stack discipline –Grows toward lower addresses –Register %esp indicates lowest stack address address of top element.
Machine-Level Programming 2 Control Flow Topics Condition Codes Setting Testing Control Flow If-then-else Varieties of Loops Switch Statements.
Precept 7: Introduction to IA-32 Assembly Language Programming
A job ad at a game programming company
Reading Condition Codes (Cont.)
Machine-Level Programming 2 Control Flow
Credits and Disclaimers
C function call conventions and the stack
Conditional Branch Example
Homework Reading Machine Projects Labs PAL, pp ,
Recitation 2 – 2/11/02 Outline Stacks & Procedures
Homework In-line Assembly Code Machine Language
Recitation 2 – 2/4/01 Outline Machine Model
Assembly Language Programming V: In-line Assembly Code
Machine-Level Programming II: Arithmetic & Control
Machine-Level Programming 1 Introduction
Machine-Level Programming III: Switch Statements and IA32 Procedures
Machine-Level Programming 4 Procedures
Instructor: David Ferry
Carnegie Mellon Machine-Level Programming III: Procedures : Introduction to Computer Systems October 22, 2015 Instructor: Rabi Mahapatra Authors:
Condition Codes Single Bit Registers
Machine-Level Programming 2 Control Flow
Instructors: Majd Sakr and Khaled Harras
Assembly Language Programming II: C Compiler Calling Sequences
Machine-Level Programming 2 Control Flow
Machine-Level Programming III: Procedures Sept 18, 2001
Machine-Level Representation of Programs III
Instructors: Majd Sakr and Khaled Harras
“Way easier than when we were students”
Credits and Disclaimers
Presentation transcript:

About the Slides for Introduction to Computer Systems 15-213: Introduction to Computer Systems 0th Lecture, Sep. 1, 2015 Markus Püschel ETH Zurich (with small contributions by Dave O’Hallaron)

On the Design All slides are in Powerpoint 2007 (mix of PC and Mac versions) Probably could be edited using Powerpoint 2003 plus File format plugin Calibri font I would still recommend to use 2007 for editing Design is suitable for printing out slides Only light colors, in particular for boxes Some slides have covered areas (that disappear later) suitable for quizzing in class The design follows the Small Guide to Giving Presentations Next slides: Color/format conventions

Instructors: Randy Bryant and Dave O’Hallaron Style for title slides System-Level I/O 15-213/18-243: Introduction to Computer Systems 14th Lecture, Oct. 12, 2010 Instructors: Randy Bryant and Dave O’Hallaron

Today Unix I/O RIO (robust I/O) package Style for outlining Unix I/O RIO (robust I/O) package Metadata, sharing, and redirection Standard I/O Conclusions and examples

Style for Figure Labels Capitalize only the first word in each figure label E.g., “Payload and padding”, not “Payload and Padding”, or “payload and padding” This is the same style convention that we used in CS:APP2e. Header Size a a = 1: Allocated block a = 0: Free block Size: Total block size Payload: Application data (allocated blocks only) Format of allocated and free blocks Payload and padding Boundary tag (footer) Size a

Style for Code /* * hello.c - Pthreads "hello, world" program */ #include "csapp.h" void *thread(void *vargp); int main() { pthread_t tid; Pthread_create(&tid, NULL, thread, NULL); Pthread_join(tid, NULL); exit(0); } /* thread routine */ void *thread(void *vargp) { printf("Hello, world!\n"); return NULL;

Style for Code and Alternative Code C Code Goto Version int fact_do(int x) { int result = 1; do { result *= x; x = x-1; } while (x > 1); return result; } int fact_goto(int x) { int result = 1; loop: result *= x; x = x-1; if (x > 1) goto loop; return result; }

Style for Assembly Code: Version I absdiff: pushl %ebp movl %esp, %ebp movl 8(%ebp), %edx movl 12(%ebp), %eax cmpl %eax, %edx jle .L7 subl %eax, %edx movl %edx, %eax .L8: leave ret .L7: subl %edx, %eax jmp .L8 int absdiff(int x, int y) { int result; if (x > y) { result = x-y; } else { result = y-x; } return result; Setup Body1 Finish Body2

Style for Assembly Code: Version II struct rec { int i; int a[3]; int *p; }; void set_p(struct rec *r) { r->p = &r->a[r->i]; } # %edx = r movl (%edx),%ecx # r->i leal 0(,%ecx,4),%eax # 4*(r->i) leal 4(%edx,%eax),%eax # r+4+4*(r->i) movl %eax,16(%edx) # Update r->p

Linux Command Prompt linux> ./badcnt BOOM! cnt=198841183

Stack and Registers Caller Frame %eax Caller-save %edx Arguments %ecx Return addr %ebx %ebp Old %ebp Callee-save %esi Saved registers + Local variables %edi %esp Special %ebp Argument build %esp

Bar Plot CPU Seconds String Length

Tables Some instructions take > 1 cycle, but can be pipelined Cycles per element (or per mult) Machine Nocona Core 2 rfact 15.5 6.0 fact 10.0 3.0 Method Int (add/mult) Float (add/mult) combine4 2.2 10.0 5.0 7.0 unroll2 1.5 unroll2-ra 1.56 2.75 3.62 bound 1.0 2.0 Some instructions take > 1 cycle, but can be pipelined Instruction Latency Cycles/Issue Load / Store 5 1 Integer Multiply 10 1 Integer/Long Divide 36/106 36/106 Single/Double FP Multiply 7 2 Single/Double FP Add 5 2 Single/Double FP Divide 32/46 32/46

Color Palette Boxes/areas: Assembly, memory, … Linux, memory, … Code, … Code, registers, … Registers, … Memory, … Occasionally I use darker versions of the colors above Text: Emphasizing something in the text Comments inside yellow code boxes