Contents. Slide Set 2. Outline of Slide Set 2. More about Pseudoinstructions. Avoid using pseudoinstructions in ENCM 369 labs

Size: px
Start display at page:

Download "Contents. Slide Set 2. Outline of Slide Set 2. More about Pseudoinstructions. Avoid using pseudoinstructions in ENCM 369 labs"

Transcription

1 Slide Set 2 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014 ENCM 369 W14 Section 01 Slide Set 2 slide 2/49 Contents ENCM 369 W14 Section 01 Slide Set 2 slide 3/49 ENCM 369 W14 Section 01 Slide Set 2 slide 4/49 (This continues material from Slide Set 1.) Pseudo are lines of A.L. that look like, but do not correspond exactly to real machine. Examples from the previous slide set include blt and la. Another example: move $t1, $t0 # copy $t0 value into $t1 The assembler will read this and generate a real machine instruction, something like this: add $t1, $zero, $t0 ENCM 369 W14 Section 01 Slide Set 2 slide 5/49 Pseudo that have real-instruction mnemonics This is one of the more confusing aspects of the MIPS assembly language. Here are a few examples... A.L. code add $t0,$t0,1 addi $s1,$s0,0x12345 lw $t9, label Remarks A true add has 3 GPR operands. Assembler generates an addi instruction. Constant too big to fit in 16 bits. Assembler generates a 3-instruction sequence. Assembler generates a 2-instruction sequence; 2nd instruction is lw with address built from GPR and offset. ENCM 369 W14 Section 01 Slide Set 2 slide 6/49 Avoid using pseudo in ENCM 369 labs Every now and then using a pseudoinstruction can save you a small amount of typing, but doing so slows down learning of the real MIPS instruction set. Exception: Use la GPR, label whenever you like. There is no convenient way to get the same effect with real. Pseudo are briefly described in Section of the textbook. The Help facility built into MARS provides separate lists of all the real and pseudo supported by MARS.

2 ENCM 369 W14 Section 01 Slide Set 2 slide 7/49 ENCM 369 W14 Section 01 Slide Set 2 slide 8/49 Procedure is the A.L. term for a thing like a C function (sometimes called a subroutine or method in other high-level languages). This is a complex topic, and will require several lectures. We ll study rules that allow coding of A.L. programs with hundreds or thousands of procedures and procedure calls! (But lab programs will usually only have 2, 3, or 4 procedures.) ENCM 369 W14 Section 01 Slide Set 2 slide 9/49 Procedures: The first few subtopics ENCM 369 W14 Section 01 Slide Set 2 slide 10/49 Procedures: Subtopics we ll get to later Flow of instruction execution, MIPS jal and jr. Passing arguments in GPRs $a0 $a3, returning a value in GPR $v0. Definitions for the terms leaf and nonleaf. Problems with conflicts over GPRs. (How can many procedures cooperate to share the same small set of GPRs?) Programming the stack in A.L. Using the stack to help with register conflicts. Using the stack to allocate local variables in memory. (Remember, some variables are in GPRs and others are in memory.) ENCM 369 W14 Section 01 Slide Set 2 slide 11/49 Flow of instruction execution, call and return operations In machine language, a procedure is just a sequence of. Suppose a program has two procedures: main and foo. Suppose main calls foo. When foo is done there is a return to main. "CALL" "RETURN" memory of main of foo lower addresses higher addresses ENCM 369 W14 Section 01 Slide Set 2 slide 12/49 Call and return operations in MIPS: jal and jr CALL: A jal (jump and link) instruction in main causes a jump to the first instruction of foo. RETURN: The last instruction in foo is a jr (jump to address in register) instruction. This causes a jump back to the instruction just after the jal instruction in main. "CALL" "RETURN" memory of main of foo lower addresses higher addresses

3 ENCM 369 W14 Section 01 Slide Set 2 slide 13/49 The concept of a return address, and the MIPS $ra register ENCM 369 W14 Section 01 Slide Set 2 slide 14/49 Differences between j, jal, and jr For the return operation in the given example program to work correctly, information had to be recorded about where to resume execution in main when foo was done. GPR 31 in MIPS, called $ra, is used for this purpose. To see how $ra is used, let s sketch out assembly language code for main and foo. j uses a label to identify the jump target. j does not touch $ra. jal uses a label, too. But jal also updates $ra to note where to come back to when the called procedure has finished. jr does not use a label instead it looks in a GPR to find the jump target address. ENCM 369 W14 Section 01 Slide Set 2 slide 15/49 Remarks about jal and jr ENCM 369 W14 Section 01 Slide Set 2 slide 16/49 Useful terms: caller and callee The word link in jump and link means remember how to come back. (But jarhtcb would be too long as an instruction mnemonic!) jr is most often used with $ra for procedure return, but can be used with other GPRs for other purposes. The r in jr stands for register, not return. A procedure call involves two procedures: the caller, and the callee. The caller makes the call to the callee. When the callee is done there is a return back to the caller. In the earlier example, main was the caller and foo was the callee. ENCM 369 W14 Section 01 Slide Set 2 slide 17/49 Arguments and return values ENCM 369 W14 Section 01 Slide Set 2 slide 18/49 Example procedure with arguments and a return value The caller sometimes needs to send argument values ( args ) to the callee. The callee sometimes needs to send a return value ( r.v. ) back to the caller. In MIPS certain GPRS are reserved for arguments and return values. Which GPRs are they and what rules govern their use? What would be correct MIPS A.L. for the following C function? int quux(int a, int b, int c) return a - b + c;

4 ENCM 369 W14 Section 01 Slide Set 2 slide 19/49 Limits to the uses of GPRs for arguments and return values ENCM 369 W14 Section 01 Slide Set 2 slide 20/49 Very important terms: leaf and nonleaf The rules we ve just learned work well, if the number of arguments is 4 and all arguments and return values are ints or pointers. What if there are > 4 arguments? What if an arg or r.v. is of type double? Or of a C struct type? Those won t fit in GPRs. We ll ignore all these issues for now, but more complicated rules do exist to handle these cases. It s very important to know what these terms mean, because they will be used a lot in upcoming discussion of how to make procedures work correctly. Let s carefully write down the definitions. Is quux (our most recent example) leaf or nonleaf? ENCM 369 W14 Section 01 Slide Set 2 slide 21/49 Examples of nonleaf procedures in C ENCM 369 W14 Section 01 Slide Set 2 slide 22/49 void f() g(); int func1(int x) if (x < 0) x = func2(x); return x + 17; int factorial(int n) if (n == 0) return 1; else return n * factorial(n - 1); Let s make some notes about each of these procedures. ENCM 369 W14 Section 01 Slide Set 2 slide 23/49 Introduction to register conflict problems ENCM 369 W14 Section 01 Slide Set 2 slide 24/49 First example of register conflict: Use of $ra Consider a program with hundreds of procedures. In MIPS there are only 32 GPRs. (ARM and x86-64 have only 16, and x86 has only 8!) It s very likely that at many times during a run of the program, two or more different procedures might simultaneously want to use a single GPR for two or more different purposes. This kind of situation is called a register conflict. For the C code on the left, a programmer proposes the A.L. on the right as a translation of f2... int f1(void); int f2(void) return 16 * f1(); # This will NOT WORK! f2: jal f1 sll $v0,$v0,4 # f2 rv = 16 * f1 rv jr $ra Let s assume that f1 is coded correctly, and that f2 is called by main. What happens when f2 runs?

5 ENCM 369 W14 Section 01 Slide Set 2 slide 25/49 How many return addresses have to be maintained at the same time? Suppose main calls alpha, alpha calls beta, beta calls gamma, and gamma calls delta. When delta is running, how many different return addresses must the program remember? ENCM 369 W14 Section 01 Slide Set 2 slide 26/49 Solution to $ra conflict problem Every nonleaf procedure needs to make a backup copy of the $ra contents before it makes any procedure calls that way, return address information will not be lost. The best place for these backup copies is a region of memory called the stack. It does not make sense to use a lot of different GPRs for different return addresses, one GPR per address that would use too many GPRs, and put a limit on how long a chain of procedure calls could be. ENCM 369 W14 Section 01 Slide Set 2 slide 27/49 The stack, and other regions in memory address space ENCM 369 W14 Section 01 Slide Set 2 slide 28/49 How the stack works in MIPS The stack is one of three main regions of memory address space used by a program. The other two are... The text segment: Where are located. (The word text is confusing are not sequences of character codes!) The data segment: Used for statically allocated data. May also be used for dynamically allocated chunks of data obtained with malloc in C or new in C++. The stack is an array of words with addresses from 0x7fff_fffc down to whatever address is in the stack pointer register $sp, which is GPR 29. How can the stack be made to grow by N words? How can it be made to shrink by N words? The bottom boundary of the stack, as shown on the handout, moves up and down as $sp is updated. ENCM 369 W14 Section 01 Slide Set 2 slide 29/49 Fixing a defect ENCM 369 W14 Section 01 Slide Set 2 slide 30/49 Which Way Is Up? Here is C code and a proposed MIPS A.L. translation from a few slides back... int f1(void); int f2(void) return 16 * f1(); # This will NOT WORK! f2: jal f1 sll $v0,$v0,4 # f2 rv = 16 * f1 rv jr $ra How can we use the stack to help in writing correct A.L. code for f2? In textbooks and manuals related to computer organization, there are many diagrams (or maps ) of memory. Some diagrams show higher addresses nearer the top of a page or screen, and others show higher addresses nearer the bottom. Lectures in this course have already done both! When reading diagrams, take time to figure out Which Way Is Up. When drawing diagrams, indicate clearly Which Way Is Up.

6 ENCM 369 W14 Section 01 Slide Set 2 slide 31/49 ENCM 369 W14 Section 01 Slide Set 2 slide 32/49 int alpha(void) // Plan: use $s0 // for b, $s1 for c. int b, c; b = beta(); c = gamma(); return c + b * 8; What if alpha s caller is also using $s0 or $s1? Or alpha s caller s caller, or alpha s caller s caller s caller? And so on... In a program with hundreds of procedures, you do NOT want to check them ALL for conflicting uses of $s0 and $s1! ENCM 369 W14 Section 01 Slide Set 2 slide 33/49 Sketch of solution to s-register conflict problem ENCM 369 W14 Section 01 Slide Set 2 slide 34/49 MIPS A.L. code for alpha Before alpha starts using $s0 or $s1, alpha should use the stack to save copies of $s0 and $s1 in case alpha s caller (or caller s caller, caller s caller s caller, etc.) is also using $s0 or $s1. After alpha has finished using $s0 and $s1, and just before alpha returns, alpha should read the old values of $s0 and $s1 back from the stack into $s0 and $s1. int alpha(void) // Plan: use $s0 // for b, $s1 for c. int b, c; b = beta(); c = gamma(); return c + b * 8; Let s write a complete A.L. implementation of alpha, then study how it will behave. ENCM 369 W14 Section 01 Slide Set 2 slide 35/49 Saving s-registers on the stack: General remarks ENCM 369 W14 Section 01 Slide Set 2 slide 36/49 Saving s-registers on the stack: General remarks The rule is: All s-registers used by a procedure should have their values saved on the stack near the beginning of that procedure, and restored from the stack near the end. The rule is really good for big programs. In a program with hundreds of procedures, every procedure can use up to eight s-registers without any worry about overwriting variables of other procedures. A possible objection: Sometimes a procedure could save and restore, for example, $s4, even though none of the caller, caller s caller, etc. were using $s4. Wouldn t this be a waste of time and stack space? Answer: Yes, that would be very slightly wasteful, but the waste is acceptable as a tradeoff for the simplicity of being able to use s-registers in any one procedure without checking s-register use in all the other procedures.

7 ENCM 369 W14 Section 01 Slide Set 2 slide 37/49 What about t-registers? ENCM 369 W14 Section 01 Slide Set 2 slide 38/49 // a, b, c are ints // in $s0, $s1, $s2. // f returns an int. c = a + b + f(7); # This might or # might not work! add $t0, $s0, $s1 # $t0 = a + b addi $a0, $zero, 7 # $a0 = 7 jal f add $s2, $t0, $v0 # c = $t0 + f rv What is dangerous about the A.L. code? How could the A.L. code be reorganized to avoid this risk? What if the C code were c = f(a) + f(b);? ENCM 369 W14 Section 01 Slide Set 2 slide 39/49 ENCM 369 W14 Section 01 Slide Set 2 slide 40/49 More useful procedure-related terms: prologue, body, epilogue A nonleaf procedure gets argument values from its caller in some or all of $a0-$a3, but may need some or all of $a0-$a3 to send argument values to its callees. Solution: Near the beginning of a procedure, incoming arguments should be copied from a-registers to other locations. After that is done, the a-registers are available for outgoing arguments. (We ve already seen a few pieces of terminology: caller, callee, leaf, nonleaf.) The prologue, body, and epilogue are all parts of procedures. Let s write down what each of these parts do. ENCM 369 W14 Section 01 Slide Set 2 slide 41/49 What are the other locations to which incoming args should be copied? ENCM 369 W14 Section 01 Slide Set 2 slide 42/49 Let s look at the A.L. code for fred for strategy (1) page 2 of the handout Two strategies can be used: (1) Copy the incoming args to s-registers in the prologue. (2) Copy the incoming args to the stack in the prologue. Pages 2 and 3 of the Jan 24/27/29 handout provide examples of both strategies. What is fred using $s0, $s1, and $s2 for? What does the stack frame of fred look like? Is the order of the in the prologue of fred important? (Could the add be done before the sw?) bob only takes one argument, in $a0. Why is it necessary for the prologue of fred to make copies of both $a0 and $a1?

8 ENCM 369 W14 Section 01 Slide Set 2 slide 43/49 Let s look at the A.L. code for fred for strategy (2) page 3 of the handout ENCM 369 W14 Section 01 Slide Set 2 slide 44/49 Which strategy is better for managing a-register conflicts? In strategy (2) the other locations for the arguments are stack slots words reserved within a procedure s stack frame. In the procedure body, access to the incoming arguments is done with lw and sw. Let s draw a diagram for the stack frame of fred, and make a few remarks about how this implementation of fred will work. copying incoming args to s-registers faster access to incoming args in body of procedure copying incoming args to stack slots prologue and epilogue are shorter reduced danger of running out of s-registers when there are a lot of incoming args and local variables So each strategy has an advantage relative to the other. ENCM 369 W14 Section 01 Slide Set 2 slide 45/49 ENCM 369 W14 Section 01 Slide Set 2 slide 46/49 Usually, local variables of nonleaf procedures can go in s-registers. Usually, local variables of leaf procedures can go in t-registers. But what if a local variable is an array? Or what if a local variable occupies a single word, but needs to have an address? In both cases, memory allocation is needed. Remember, registers do not have addresses! ENCM 369 W14 Section 01 Slide Set 2 slide 47/49 Example of local variables on the stack page 4 of Jan 24/27/29 handout The C function test_negatives has 3 local variables: count, sum, and x. count and sum need to have addresses, because &count and &sum are used in the call to negatives. So count and sum must be in memory. x is an array, so it too must be in memory. Solution: make space within the stack frame of test_negatives for count, sum, and x. Let s sketch a stack frame for test_negatives and write down a few remarks about it. ENCM 369 W14 Section 01 Slide Set 2 slide 48/49 A note about the test_negatives example The A.L. code for test_negatives did not use any s-registers, because all of the local variables of test_negatives had to be in memory. A more typical procedure might use s-registers for some local variables, and stack slots for other local variables.

9 ENCM 369 W14 Section 01 Slide Set 2 slide 49/49 Moving on... Lectures material on procedures and procedure calling conventions is now mostly finished. Pay attention to Lab 3 and Lab 4 exercises designed to help you learn this material.

ENCM 369 Winter 2017 Lab 3 for the Week of January 30

ENCM 369 Winter 2017 Lab 3 for the Week of January 30 page 1 of 11 ENCM 369 Winter 2017 Lab 3 for the Week of January 30 Steve Norman Department of Electrical & Computer Engineering University of Calgary January 2017 Lab instructions and other documents for

More information

Slide Set 1 (corrected)

Slide Set 1 (corrected) Slide Set 1 (corrected) for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary January 2018 ENCM 369 Winter 2018

More information

Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides

Contents. Slide Set 1. About these slides. Outline of Slide Set 1. Typographical conventions: Italics. Typographical conventions. About these slides Slide Set 1 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014 ENCM 369 W14 Section

More information

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

Slide Set 4. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 4 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary January 2018 ENCM 369 Winter 2018 Section

More information

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

Slide Set 3. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 3 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary January 2018 ENCM 369 Winter 2018 Section

More information

Implementing Procedure Calls

Implementing Procedure Calls 1 / 39 Implementing Procedure Calls February 18 22, 2013 2 / 39 Outline Intro to procedure calls Caller vs. callee Procedure call basics Calling conventions The stack Interacting with the stack Structure

More information

Slides for Lecture 15

Slides for Lecture 15 Slides for Lecture 15 ENCM 501: Principles of Computer Architecture Winter 2014 Term Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 6 March,

More information

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

Slide Set 9. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 9 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary March 2018 ENCM 369 Winter 2018 Section 01

More information

Subroutines. int main() { int i, j; i = 5; j = celtokel(i); i = j; return 0;}

Subroutines. int main() { int i, j; i = 5; j = celtokel(i); i = j; return 0;} Subroutines Also called procedures or functions Example C code: int main() { int i, j; i = 5; j = celtokel(i); i = j; return 0;} // subroutine converts Celsius to kelvin int celtokel(int i) { return (i

More information

EN164: Design of Computing Systems Lecture 11: Processor / ISA 4

EN164: Design of Computing Systems Lecture 11: Processor / ISA 4 EN164: Design of Computing Systems Lecture 11: Processor / ISA 4 Professor Sherief Reda http://scale.engin.brown.edu Electrical Sciences and Computer Engineering School of Engineering Brown University

More information

Common Problems on Homework

Common Problems on Homework MIPS Functions Common Problems on Homework 1.3: Convert -3000 ten to binary in 8bit, 16bit, and 32bit Even though it overflows with 8bits, there is plenty of room with 16 and 32 bit. Common Problems on

More information

Course Administration

Course Administration Fall 2018 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture Introduction 4/4 Avinash Karanth Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701

More information

CS 61c: Great Ideas in Computer Architecture

CS 61c: Great Ideas in Computer Architecture MIPS Functions July 1, 2014 Review I RISC Design Principles Smaller is faster: 32 registers, fewer instructions Keep it simple: rigid syntax, fixed instruction length MIPS Registers: $s0-$s7,$t0-$t9, $0

More information

Slide Set 5. for ENCM 369 Winter 2014 Lecture Section 01. Steve Norman, PhD, PEng

Slide Set 5. for ENCM 369 Winter 2014 Lecture Section 01. Steve Norman, PhD, PEng Slide Set 5 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014 ENCM 369 W14 Section

More information

MIPS Functions and Instruction Formats

MIPS Functions and Instruction Formats MIPS Functions and Instruction Formats 1 The Contract: The MIPS Calling Convention You write functions, your compiler writes functions, other compilers write functions And all your functions call other

More information

Storage in Programs. largest. address. address

Storage in Programs. largest. address. address Storage in rograms Almost all operand storage used by programs is provided by memory. Even though registers are more efficiently accessed by instructions, there are too few registers to hold the stored

More information

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture COMP 303 Computer Architecture Lecture 3 Comp 303 Computer Architecture 1 Supporting procedures in computer hardware The execution of a procedure Place parameters in a place where the procedure can access

More information

Winter 2017 MIDTERM TEST #1 Wednesday, February 8 7:00pm to 8:30pm. Please do not write your U of C ID number on this cover page.

Winter 2017 MIDTERM TEST #1 Wednesday, February 8 7:00pm to 8:30pm. Please do not write your U of C ID number on this cover page. page 1 of 5 University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructors: Steve Norman and Norm Bartley Winter 2017 MIDTERM TEST #1 Wednesday,

More information

Functions in MIPS. Functions in MIPS 1

Functions in MIPS. Functions in MIPS 1 Functions in MIPS We ll talk about the 3 steps in handling function calls: 1. The program s flow of control must be changed. 2. Arguments and return values are passed back and forth. 3. Local variables

More information

Lecture 5. Announcements: Today: Finish up functions in MIPS

Lecture 5. Announcements: Today: Finish up functions in MIPS Lecture 5 Announcements: Today: Finish up functions in MIPS 1 Control flow in C Invoking a function changes the control flow of a program twice. 1. Calling the function 2. Returning from the function In

More information

MIPS Functions and the Runtime Stack

MIPS Functions and the Runtime Stack MIPS Functions and the Runtime Stack COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline

More information

Today. Putting it all together

Today. Putting it all together Today! One complete example To put together the snippets of assembly code we have seen! Functions in MIPS Slides adapted from Josep Torrellas, Craig Zilles, and Howard Huang Putting it all together! Count

More information

CSE Lecture In Class Example Handout

CSE Lecture In Class Example Handout CSE 30321 Lecture 07-09 In Class Example Handout Part A: A Simple, MIPS-based Procedure: Swap Procedure Example: Let s write the MIPS code for the following statement (and function call): if (A[i] > A

More information

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: MIPS Programming Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring 2009 Topic Notes: MIPS Programming We spent some time looking at the MIPS Instruction Set Architecture. We will now consider

More information

Lab 4 Prelab: MIPS Function Calls

Lab 4 Prelab: MIPS Function Calls Lab 4 Prelab: MIPS Function Calls Name: Sign the following statement: On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work 1 Objective The main objective of

More information

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2)

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2) ELEC 5200-001/6200-001 Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2) Victor P. Nelson, Professor & Asst. Chair Vishwani D. Agrawal, James J. Danaher Professor Department

More information

Slide Set 1. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 1. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 1 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2016 ENCM 339 Fall 2016 Slide Set 1 slide 2/43

More information

Function Calling Conventions 1 CS 64: Computer Organization and Design Logic Lecture #9

Function Calling Conventions 1 CS 64: Computer Organization and Design Logic Lecture #9 Function Calling Conventions 1 CS 64: Computer Organization and Design Logic Lecture #9 Ziad Matni Dept. of Computer Science, UCSB Lecture Outline More on MIPS Calling Convention Functions calling functions

More information

COMP2611: Computer Organization MIPS function and recursion

COMP2611: Computer Organization MIPS function and recursion COMP2611 Fall2015 COMP2611: Computer Organization MIPS function and recursion Overview 2 You will learn the following in this lab: how to use MIPS functions in a program; the concept of recursion; how

More information

Anne Bracy CS 3410 Computer Science Cornell University

Anne Bracy CS 3410 Computer Science Cornell University Anne Bracy CS 3410 Computer Science Cornell University The slides are the product of many rounds of teaching CS 3410 by Professors Weatherspoon, Bala, Bracy, McKee, and Sirer. See P&H 2.8 and 2.12, and

More information

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

Slide Set 5. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 5 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary February 2018 ENCM 369 Winter 2018 Section

More information

CPS311 Lecture: Procedures Last revised 9/9/13. Objectives:

CPS311 Lecture: Procedures Last revised 9/9/13. Objectives: CPS311 Lecture: Procedures Last revised 9/9/13 Objectives: 1. To introduce general issues that any architecture must address in terms of calling/returning from procedures, passing parameters (including

More information

CA Compiler Construction

CA Compiler Construction CA4003 - Compiler Construction David Sinclair When procedure A calls procedure B, we name procedure A the caller and procedure B the callee. A Runtime Environment, also called an Activation Record, is

More information

Slide Set 3. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng

Slide Set 3. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng Slide Set 3 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2017 ENCM 339 Fall 2017 Section 01

More information

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary Control Instructions Computer Organization Architectures for Embedded Computing Thursday, 26 September 2013 Many slides adapted from: Computer Organization and Design, Patterson & Hennessy 4th Edition,

More information

Control Instructions

Control Instructions Control Instructions Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class Instruction Set

More information

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions Procedure Calls A procedure of a subroutine is like an agent which needs certain information to perform a

More information

Lectures 5. Announcements: Today: Oops in Strings/pointers (example from last time) Functions in MIPS

Lectures 5. Announcements: Today: Oops in Strings/pointers (example from last time) Functions in MIPS Lectures 5 Announcements: Today: Oops in Strings/pointers (example from last time) Functions in MIPS 1 OOPS - What does this C code do? int foo(char *s) { int L = 0; while (*s++) { ++L; } return L; } 2

More information

Winter 2003 MID-SESSION TEST Monday, March 10 6:30 to 8:00pm

Winter 2003 MID-SESSION TEST Monday, March 10 6:30 to 8:00pm University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructors: Dr. S. A. Norman (L01) and Dr. S. Yanushkevich (L02) Winter 2003 MID-SESSION TEST Monday,

More information

Lecture 5: Procedure Calls

Lecture 5: Procedure Calls Lecture 5: Procedure Calls Today s topics: Procedure calls and register saving conventions 1 Example Convert to assembly: while (save[i] == k) i += 1; i and k are in $s3 and $s5 and base of array save[]

More information

CS64 Week 5 Lecture 1. Kyle Dewey

CS64 Week 5 Lecture 1. Kyle Dewey CS64 Week 5 Lecture 1 Kyle Dewey Overview More branches in MIPS Memory in MIPS MIPS Calling Convention More Branches in MIPS else_if.asm nested_if.asm nested_else_if.asm Memory in MIPS Accessing Memory

More information

EE 361 University of Hawaii Fall

EE 361 University of Hawaii Fall C functions Road Map Computation flow Implementation using MIPS instructions Useful new instructions Addressing modes Stack data structure 1 EE 361 University of Hawaii Implementation of C functions and

More information

Anne Bracy CS 3410 Computer Science Cornell University

Anne Bracy CS 3410 Computer Science Cornell University Anne Bracy CS 3410 Computer Science Cornell University The slides are the product of many rounds of teaching CS 3410 by Professors Weatherspoon, Bala, Bracy, McKee, and Sirer. compute jump/branch targets

More information

ENCM 339 Fall 2017 Tutorial for Week 8

ENCM 339 Fall 2017 Tutorial for Week 8 ENCM 339 Fall 2017 Tutorial for Week 8 for section T01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 2 November, 2017 ENCM 339 T01 Tutorial

More information

Calling Conventions. Hakim Weatherspoon CS 3410, Spring 2012 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 Calling Conventions Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University See P&H 2.8 and 2.12 Goals for Today Calling Convention for Procedure Calls Enable code to be reused by allowing

More information

Lecture 5: Procedure Calls

Lecture 5: Procedure Calls Lecture 5: Procedure Calls Today s topics: Memory layout, numbers, control instructions Procedure calls 1 Memory Organization The space allocated on stack by a procedure is termed the activation record

More information

Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University. See P&H 2.8 and 2.12, and A.

Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University. See P&H 2.8 and 2.12, and A. Prof. Kavita Bala and Prof. Hakim Weatherspoon CS 3410, Spring 2014 Computer Science Cornell University See P&H 2.8 and 2.12, and A.5 6 compute jump/branch targets memory PC +4 new pc Instruction Fetch

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c/su06 CS61C : Machine Structures Lecture #9: MIPS Procedures 2006-07-11 CS 61C L09 MIPS Procedures (1) Andy Carle C functions main() { int i,j,k,m;... i = mult(j,k);... m =

More information

SPIM Procedure Calls

SPIM Procedure Calls SPIM Procedure Calls 22C:60 Jonathan Hall March 29, 2008 1 Motivation We would like to create procedures that are easy to use and easy to read. To this end we will discuss standard conventions as it relates

More information

Lecture 6: Assembly Programs

Lecture 6: Assembly Programs Lecture 6: Assembly Programs Today s topics: Procedures Examples Large constants The compilation process A full example 1 Procedures Local variables, AR, $fp, $sp Scratchpad and saves/restores, $fp Arguments

More information

Memory Usage 0x7fffffff. stack. dynamic data. static data 0x Code Reserved 0x x A software convention

Memory Usage 0x7fffffff. stack. dynamic data. static data 0x Code Reserved 0x x A software convention Subroutines Why we use subroutines more modular program (small routines, outside data passed in) more readable, easier to debug code reuse i.e. smaller code space Memory Usage A software convention stack

More information

ECE260: Fundamentals of Computer Engineering. Supporting Procedures in Computer Hardware

ECE260: Fundamentals of Computer Engineering. Supporting Procedures in Computer Hardware Supporting Procedures in Computer Hardware James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy

More information

Chapter 3. Instructions:

Chapter 3. Instructions: Chapter 3 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 8: Procedures (cont d), Binary Numbers and Adders Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Review: Procedure Calling Steps

More information

Slide Set 3. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Slide Set 3. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary Slide Set 3 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2016 ENCM 339 Fall 2016 Slide Set 3 slide 2/46

More information

2/16/2018. Procedures, the basic idea. MIPS Procedure convention. Example: compute multiplication. Re-write it as a MIPS procedure

2/16/2018. Procedures, the basic idea. MIPS Procedure convention. Example: compute multiplication. Re-write it as a MIPS procedure Procedures, the basic idea CSCI206 - Computer Organization & Programming Introduction to Procedures zybook: 81 (for next class) MIPS Procedure convention 1 Prepare parameters in $a0 through $a3 2 Return

More information

ECE232: Hardware Organization and Design

ECE232: Hardware Organization and Design ECE232: Hardware Organization and Design Lecture 6: Procedures Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Overview Procedures have different names in different languages Java:

More information

See P&H 2.8 and 2.12, and A.5-6. Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University

See P&H 2.8 and 2.12, and A.5-6. Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See P&H 2.8 and 2.12, and A.5-6 Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University Upcoming agenda PA1 due yesterday PA2 available and discussed during lab section this week

More information

Procedures and Stacks

Procedures and Stacks Procedures and Stacks Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. March 15, 2018 L10-1 Announcements Schedule has shifted due to snow day Quiz 2 is now on Thu 4/12 (one week later)

More information

CENG3420 Computer Organization and Design Lab 1-2: System calls and recursions

CENG3420 Computer Organization and Design Lab 1-2: System calls and recursions CENG3420 Computer Organization and Design Lab 1-2: System calls and recursions Wen Zong Department of Computer Science and Engineering The Chinese University of Hong Kong wzong@cse.cuhk.edu.hk Overview

More information

Review of Activation Frames. FP of caller Y X Return value A B C

Review of Activation Frames. FP of caller Y X Return value A B C Review of Activation Frames In general, activation frames are organized like this: HI LO Bookkeeping/preserved registers I/O parameters Locals and temps RA of caller FP of caller Y X Return value A B C

More information

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering Supporting Nested Procedures James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy Memory Layout

More information

Procedure Call and Return Procedure call

Procedure Call and Return Procedure call Procedures int len(char *s) { for (int l=0; *s!= \0 ; s++) l++; main return l; } void reverse(char *s, char *r) { char *p, *t; int l = len(s); reverse(s,r) N/A *(r+l) = \0 ; reverse l--; for (p=s+l t=r;

More information

ENCM 501 Winter 2019 Assignment 9

ENCM 501 Winter 2019 Assignment 9 page 1 of 6 ENCM 501 Winter 2019 Assignment 9 Steve Norman Department of Electrical & Computer Engineering University of Calgary April 2019 Assignment instructions and other documents for ENCM 501 can

More information

CS61C Machine Structures. Lecture 12 - MIPS Procedures II & Logical Ops. 2/13/2006 John Wawrzynek. www-inst.eecs.berkeley.

CS61C Machine Structures. Lecture 12 - MIPS Procedures II & Logical Ops. 2/13/2006 John Wawrzynek. www-inst.eecs.berkeley. CS61C Machine Structures Lecture 12 - MIPS Procedures II & Logical Ops 2/13/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L12 MIPS Procedures II / Logical (1)

More information

Slide Set 7. for ENCM 501 in Winter Term, Steve Norman, PhD, PEng

Slide Set 7. for ENCM 501 in Winter Term, Steve Norman, PhD, PEng Slide Set 7 for ENCM 501 in Winter Term, 2017 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2017 ENCM 501 W17 Lectures: Slide

More information

Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero

Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero Do-While Example In C++ do { z--; while (a == b); z = b; In assembly language loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero 25 Comparisons Set on less than (slt) compares its source registers

More information

Compiling Code, Procedures and Stacks

Compiling Code, Procedures and Stacks Compiling Code, Procedures and Stacks L03-1 RISC-V Recap Computational Instructions executed by ALU Register-Register: op dest, src1, src2 Register-Immediate: op dest, src1, const Control flow instructions

More information

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont ) Chapter 2 Computer Abstractions and Technology Lesson 4: MIPS (cont ) Logical Operations Instructions for bitwise manipulation Operation C Java MIPS Shift left >>> srl Bitwise

More information

Code Generation. Lecture 12

Code Generation. Lecture 12 Code Generation Lecture 12 1 Lecture Outline Topic 1: Basic Code Generation The MIPS assembly language A simple source language Stack-machine implementation of the simple language Topic 2: Code Generation

More information

Lecture 7: Examples, MARS, Arithmetic

Lecture 7: Examples, MARS, Arithmetic Lecture 7: Examples, MARS, Arithmetic Today s topics: More examples MARS intro Numerical representations 1 Dealing with Characters Instructions are also provided to deal with byte-sized and half-word quantities:

More information

Function Calls. 1 Administrivia. Tom Kelliher, CS 240. Feb. 13, Announcements. Collect homework. Assignment. Read

Function Calls. 1 Administrivia. Tom Kelliher, CS 240. Feb. 13, Announcements. Collect homework. Assignment. Read Function Calls Tom Kelliher, CS 240 Feb. 13, 2002 1 Administrivia Announcements Collect homework. Assignment Read 3.7 9. From Last Time SPIM lab. Outline 1. Function calls: stack execution model, memory

More information

CSE Lecture In Class Example Handout

CSE Lecture In Class Example Handout CSE 30321 Lecture 07-08 In Class Example Handout Part A: J-Type Example: If you look in your book at the syntax for j (an unconditional jump instruction), you see something like: e.g. j addr would seemingly

More information

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

Slide Set 8. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 8 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary March 2018 ENCM 369 Winter 2018 Section 01

More information

Computer Hardware Engineering

Computer Hardware Engineering 2 Course Structure Computer Hardware ngineering IS1200, spring 2015 Lecture 3: Languages Module 4: I/O Systems Module 1: Logic Design L DCÖ1 L DCÖ2 Lab:dicom L7 Module 2: C and Assembly Programming Associate

More information

Compilers and computer architecture: A realistic compiler to MIPS

Compilers and computer architecture: A realistic compiler to MIPS 1 / 1 Compilers and computer architecture: A realistic compiler to MIPS Martin Berger November 2017 Recall the function of compilers 2 / 1 3 / 1 Recall the structure of compilers Source program Lexical

More information

Instruction Set Architectures (4)

Instruction Set Architectures (4) Computer Architecture Week 06 Instruction Set Architectures (4) College of Information Science and Engineering Ritsumeikan University subroutines functions, procedures remember the next instruction s address

More information

Function Calls. Tom Kelliher, CS 220. Oct. 24, SPIM programs due Wednesday. Refer to homework handout for what to turn in, and how.

Function Calls. Tom Kelliher, CS 220. Oct. 24, SPIM programs due Wednesday. Refer to homework handout for what to turn in, and how. Function Calls Tom Kelliher, CS 220 Oct. 24, 2011 1 Administrivia Announcements Assignment SPIM programs due Wednesday. Refer to homework handout for what to turn in, and how. From Last Time Outline 1.

More information

Shift and Rotate Instructions

Shift and Rotate Instructions Shift and Rotate Instructions Shift and rotate instructions facilitate manipulations of data (that is, modifying part of a 32-bit data word). Such operations might include: Re-arrangement of bytes in a

More information

#1 #2 with corrections Monday, March 12 7:00pm to 8:30pm. Please do not write your U of C ID number on this cover page.

#1 #2 with corrections Monday, March 12 7:00pm to 8:30pm. Please do not write your U of C ID number on this cover page. page 1 of 6 University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructors: Steve Norman and Norm Bartley Winter 2018 MIDTERM TEST #1 #2 with

More information

Slide Set 11. for ENCM 369 Winter 2015 Lecture Section 01. Steve Norman, PhD, PEng

Slide Set 11. for ENCM 369 Winter 2015 Lecture Section 01. Steve Norman, PhD, PEng Slide Set 11 for ENCM 369 Winter 2015 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2015 ENCM 369 W15 Section

More information

Instructions: MIPS arithmetic. MIPS arithmetic. Chapter 3 : MIPS Downloaded from:

Instructions: MIPS arithmetic. MIPS arithmetic. Chapter 3 : MIPS Downloaded from: Instructions: Chapter 3 : MIPS Downloaded from: http://www.cs.umr.edu/~bsiever/cs234/ Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive

More information

We will study the MIPS assembly language as an exemplar of the concept.

We will study the MIPS assembly language as an exemplar of the concept. MIPS Assembly Language 1 We will study the MIPS assembly language as an exemplar of the concept. MIPS assembly instructions each consist of a single token specifying the command to be carried out, and

More information

CS 61C: Great Ideas in Computer Architecture More MIPS, MIPS Functions

CS 61C: Great Ideas in Computer Architecture More MIPS, MIPS Functions CS 61C: Great Ideas in Computer Architecture More MIPS, MIPS Functions Instructors: John Wawrzynek & Vladimir Stojanovic http://inst.eecs.berkeley.edu/~cs61c/fa15 1 Machine Interpretation Levels of Representation/Interpretation

More information

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015 Branch Addressing Branch instructions specify Opcode, two registers, target address Most branch targets are near branch Forward or backward op rs rt constant or address 6 bits 5 bits 5 bits 16 bits PC-relative

More information

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands Stored Program Concept Instructions: Instructions are bits Programs are stored in memory to be read or written just like data Processor Memory memory for data, programs, compilers, editors, etc. Fetch

More information

Lecture 7: Procedures and Program Execution Preview

Lecture 7: Procedures and Program Execution Preview Lecture 7: Procedures and Program Execution Preview CSE 30: Computer Organization and Systems Programming Winter 2010 Rajesh Gupta / Ryan Kastner Dept. of Computer Science and Engineering University of

More information

Winter 2012 MID-SESSION TEST Tuesday, March 6 6:30pm to 8:15pm. Please do not write your U of C ID number on this cover page.

Winter 2012 MID-SESSION TEST Tuesday, March 6 6:30pm to 8:15pm. Please do not write your U of C ID number on this cover page. University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructors: S. A. Norman and N. R. Bartley Winter 2012 MID-SESSION TEST Tuesday, March 6

More information

Procedure Calls Main Procedure. MIPS Calling Convention. MIPS-specific info. Procedure Calls. MIPS-specific info who cares? Chapter 2.7 Appendix A.

Procedure Calls Main Procedure. MIPS Calling Convention. MIPS-specific info. Procedure Calls. MIPS-specific info who cares? Chapter 2.7 Appendix A. MIPS Calling Convention Chapter 2.7 Appendix A.6 Procedure Calls Main Procedure Call Procedure Call Procedure Procedure Calls Procedure must from any call Procedure uses that main was using We need a convention

More information

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng Slide Set 2 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 2 slide

More information

ENCM 369 Winter 2016 Lab 11 for the Week of April 4

ENCM 369 Winter 2016 Lab 11 for the Week of April 4 page 1 of 13 ENCM 369 Winter 2016 Lab 11 for the Week of April 4 Steve Norman Department of Electrical & Computer Engineering University of Calgary April 2016 Lab instructions and other documents for ENCM

More information

CS 316: Procedure Calls/Pipelining

CS 316: Procedure Calls/Pipelining CS 316: Procedure Calls/Pipelining Kavita Bala Fall 2007 Computer Science Cornell University Announcements PA 3 IS out today Lectures on it this Fri and next Tue/Thu Due on the Friday after Fall break

More information

Chapter 2. Instructions:

Chapter 2. Instructions: Chapter 2 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with

More information

CS153: Compilers Lecture 8: Compiling Calls

CS153: Compilers Lecture 8: Compiling Calls CS153: Compilers Lecture 8: Compiling Calls Stephen Chong https://www.seas.harvard.edu/courses/cs153 Announcements Project 2 out Due Thu Oct 4 (7 days) Project 3 out Due Tuesday Oct 9 (12 days) Reminder:

More information

Computer Architecture. Chapter 2-2. Instructions: Language of the Computer

Computer Architecture. Chapter 2-2. Instructions: Language of the Computer Computer Architecture Chapter 2-2 Instructions: Language of the Computer 1 Procedures A major program structuring mechanism Calling & returning from a procedure requires a protocol. The protocol is a sequence

More information

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu School of Engineering Brown University Spring 2014 Sources: Computer

More information

MIPS Programming. A basic rule is: try to be mechanical (that is, don't be "tricky") when you translate high-level code into assembler code.

MIPS Programming. A basic rule is: try to be mechanical (that is, don't be tricky) when you translate high-level code into assembler code. MIPS Programming This is your crash course in assembler programming; you will teach yourself how to program in assembler for the MIPS processor. You will learn how to use the instruction set summary to

More information

CS 110 Computer Architecture Lecture 6: More MIPS, MIPS Functions

CS 110 Computer Architecture Lecture 6: More MIPS, MIPS Functions CS 110 Computer Architecture Lecture 6: More MIPS, MIPS Functions Instructor: Sören Schwertfeger http://shtech.org/courses/ca/ School of Information Science and Technology SIST ShanghaiTech University

More information

Contents Slide Set 9. Final Notes on Textbook Chapter 7. Outline of Slide Set 9. More about skipped sections in Chapter 7. Outline of Slide Set 9

Contents Slide Set 9. Final Notes on Textbook Chapter 7. Outline of Slide Set 9. More about skipped sections in Chapter 7. Outline of Slide Set 9 slide 2/41 Contents Slide Set 9 for ENCM 369 Winter 2014 Lecture Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Winter Term, 2014

More information

Anne Bracy CS 3410 Computer Science Cornell University

Anne Bracy CS 3410 Computer Science Cornell University Anne Bracy CS 3410 Computer Science Cornell University The slides are the product of many rounds of teaching CS 3410 by Professors Weatherspoon, Bala, Bracy, McKee, and Sirer. See P&H 2.8 and 2.12, and

More information