Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Prelim Review.

Slides:



Advertisements
Similar presentations
Calling sequence ESP.
Advertisements

CS 4284 Systems Capstone Godmar Back Processes and Threads.
Procedures in more detail. CMPE12cGabriel Hugh Elkaim 2 Why use procedures? –Code reuse –More readable code –Less code Microprocessors (and assembly languages)
Procedure Calls Prof. Sirer CS 316 Cornell University.
Lecture 6: MIPS Instruction Set Today’s topic –Control instructions –Procedure call/return 1.
Computer Architecture CSCE 350
Pipeline Enhancements for the Y86 Architecture
1 Today  Remember to use your late days wisely —We can’t post solutions until all HWs have been turned in  One complete example —To put together the.
Calling Conventions Hakim Weatherspoon CS 3410, Spring 2011 Computer Science Cornell University See P&H 2.8 and 2.12.
Pipeline Control Hazards and Instruction Variations Hakim Weatherspoon CS 3410, Spring 2011 Computer Science Cornell University See P&H Appendix 4.8 &
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.
1 Storage Registers vs. memory Access to registers is much faster than access to memory Goal: store as much data as possible in registers Limitations/considerations:
Context Switch Animation Another one by Anastasia.
Machine-Level Programming III: Procedures Apr. 17, 2006 Topics IA32 stack discipline Register saving conventions Creating pointers to local variables CS213.
Procedures in more detail. CMPE12cCyrus Bazeghi 2 Procedures Why use procedures? Reuse of code More readable Less code Microprocessors (and assembly languages)
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)
Accessing parameters from the stack and calling functions.
– 1 – , F’02 ICS05 Instructor: Peter A. Dinda TA: Bin Lin Recitation 4.
Assembly Language for Intel-Based Computers Chapter 2: IA-32 Processor Architecture Kip Irvine.
Assembly תרגול 8 פונקציות והתקפת buffer.. Procedures (Functions) A procedure call involves passing both data and control from one part of the code to.
Stack Activation Records Topics IA32 stack discipline Register saving conventions Creating pointers to local variables February 6, 2003 CSCE 212H Computer.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Stack Operations Runtime Stack PUSH Operation POP.
Calling Conventions Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See P&H 2.8 and 2.12.
6.828: PC hardware and x86 Frans Kaashoek
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 7 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Memory/Storage Architecture Lab Computer Architecture MIPS Instruction Set Architecture ( Supporting Procedures )
Assembly Questions תרגול 12.
Code Generation Gülfem Savrun Yeniçeri CS 142 (b) 02/26/2013.
CSc 453 Runtime Environments Saumya Debray The University of Arizona Tucson.
Fabián E. Bustamante, Spring 2007 Machine-Level Programming III - Procedures Today IA32 stack discipline Register saving conventions Creating pointers.
Functions and Procedures. Function or Procedure u A separate piece of code u Possibly separately compiled u Located at some address in the memory used.
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Execution of Machine Code Machine State and Operations Apps O/S.
Lecture 18: 11/5/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Procedures. Why use procedures? ? Microprocessors (and assembly languages) provide only minimal support for procedures Must build a standard form for.
Activation Records (in Tiger) CS 471 October 24, 2007.
Lecture 19: 11/7/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Procedure (Method) Calls Ellen Spertus MCS 111 September 25, 2003.
Calling Conventions Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See P&H 2.8 and 2.12.
Calling Conventions Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See P&H 2.8 and 2.12.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 21: Calling.
Calling Conventions Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See P&H 2.8 and 2.12.
Machine-level Programming III: Procedures Topics –IA32 stack discipline –Register saving conventions –Creating pointers to local variables.
1 Seoul National University Pipelining Basics. 2 Sequential Processing Seoul National University.
Computer Architecture CSE 3322 Lecture 4 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/10/09
Compiler Construction Code Generation Activation Records
University of Amsterdam Computer Systems – the instruction set architecture Arnoud Visser 1 Computer Systems The instruction set architecture.
1 Assembly Language: Function Calls Jennifer Rexford.
CSC 221 Computer Organization and Assembly Language Lecture 15: STACK Related Instructions.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
ICS51 Introductory Computer Organization Accessing parameters from the stack and calling functions.
Assembly function call convention
Computer Science 210 Computer Organization
C function call conventions and the stack
CS-401 Computer Architecture & Assembly Language Programming
© Craig Zilles (adapted from slides by Howard Huang)
Introduction to Compilers Tim Teitelbaum
Functions and Procedures
Prof. Hakim Weatherspoon
Prof. Hakim Weatherspoon
MIPS Instructions.
Machine-Level Programming III: Procedures Sept 18, 2001
MIPS Procedure Calls CSE 378 – Section 3.
Multi-modules programming
Computer Architecture CST 250
02/02/10 20:53 Assembly Questions תרגול 12 1.
© Craig Zilles (adapted from slides by Howard Huang)
Presentation transcript:

Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Prelim Review

2 FAQ caller/callee saved registers CPI writing assembling reading assembly

3 Caller-saved vs. Callee-saved Caller-save: If necessary… ($t0.. $t9) save before calling anything; restore after it returns Callee-save: Always… ($s0.. $s7) save before modifying; restore before returning Caller-save registers are responsibility of the caller Caller-save register values saved only if used after call/return The callee function can use caller-saved registers with concern Callee-save register are the responsibility of the callee Values must be saved by callee before they can be used Caller can assume that these registers will be restored

4 Caller-saved vs. Callee-saved Caller-save: If necessary… ($t0.. $t9) save before calling anything; restore after it returns Callee-save: Always… ($s0.. $s7) save before modifying; restore before returning eax, ecx, and edx are caller-save… … a function can freely modify these registers … but must assume that their contents have been destroyed if it in turns calls a function. ebx, esi, edi, ebp, esp are callee-save A function may call another function and know that the callee-save registers have not been modified However, if it modifies these registers itself, it must restore them to their original values before returning.

5 Caller-saved vs. Callee-saved Caller-save: If necessary… ($t0.. $t9) save before calling anything; restore after it returns Callee-save: Always… ($s0.. $s7) save before modifying; restore before returning A caller-save register must be saved and restored around any call to a subprogram. In contrast, for a callee-save register, a caller need do no extra work at a call site (the callee saves and restores the register if it is used).

6 Caller-saved vs. Callee-saved Caller-save: If necessary… ($t0.. $t9) save before calling anything; restore after it returns Callee-save: Always… ($s0.. $s7) save before modifying; restore before returning CALLER SAVED: MIPS calls these temporary registers, $t0-t9 the calling program saves the registers that it does not want a called procedure to overwrite register values are NOT preserved across procedure calls CALLEE SAVED: MIPS calls these saved registers, $s0-s8 register values are preserved across procedure calls the called procedure saves register values in its AR, uses the registers for local variables, restores register values before it returns.

7 Caller-saved vs. Callee-saved Caller-save: If necessary… ($t0.. $t9) save before calling anything; restore after it returns Callee-save: Always… ($s0.. $s7) save before modifying; restore before returning Registers $t0-$t9 are caller-saved registers … that are used to hold temporary quantities … that need not be preserved across calls Registers $s0-s8 are callee-saved registers … that hold long-lived values … that should be preserved across calls caller-saved register A register saved by the routine being called callee-saved register A register saved by the routine making a procedure call.

8 What is it? CPI Cycles Per Instruction A measure of latency (delay)? “ADD takes 5 cycles to finish” or A measure of throughput? “N ADDs are completed in N cycles”

9 CPI = weighted average throughput over all instructions in a given workload CPI = 1.0 means that on average… … an instruction is completed every 1 cycle CPI = 2.0 means that on average… … an instruction is completed every 2 cycles CPI = 5.0 means that on average… … an instruction is completed every 5 cycles

10 Example CPI = 1.0 CPI = 1.0 means that on average… … an instruction is completed every 1 cycle

11 Example CPI = 2.0 CPI = 2.0 means that on average… … an instruction is completed every 2 cycles

12 Example CPI = 0.5 CPI = 0.5 means that on average… … an instruction is completed every 0.5 cycles

13 CPI Calculation Suppose 10 stage pipeline and… 1 instruction zapped on every taken jump or branch 3 stalls for every memory operation Q: What is CPI? … for pure arithmetic workload? … for pure memory workload? … for pure jump workload? … for 50/50 arithmetic/jump workload? … for 50%/25%/25% arith/mem/branch? … if one fifth of the branches are taken?