# Lecture 14: Recap. Today s topics: Recap for mid-term No electronic devices in midterm

Save this PDF as:

Size: px
Start display at page:

Download "Lecture 14: Recap. Today s topics: Recap for mid-term No electronic devices in midterm"

## Transcription

1 Lecture 14: Recap Today s topics: Recap for mid-term No electronic devices in midterm 1

2 Modern Trends Historical contributions to performance: Better processes (faster devices) ~20% Better circuits/pipelines ~15% Better organization/architecture ~15% Today, annual improvement is closer to 20%; this is primarily because of slowly increasing transistor count and more cores. Need multi-thread parallelism and accelerators to boost performance every year. 2

3 Performance Measures Performance = 1 / execution time Speedup = ratio of performance Performance improvement = speedup -1 Execution time = clock cycle time x CPI x number of instrs Program takes 100 seconds on ProcA and 150 seconds on ProcB Speedup of A over B = 150/100 = 1.5 Performance improvement of A over B = = 0.5 = 50% Speedup of B over A = 100/150 = 0.66 (speedup less than 1 means performance went down) Performance improvement of B over A = = = -33% or Performance degradation of B, relative to A = 33% If multiple programs are executed, the execution times are combined into a single number using AM, weighted AM, or GM 3

4 Performance Equations CPU execution time = CPU clock cycles x Clock cycle time CPU clock cycles = number of instrs x avg clock cycles per instruction (CPI) Substituting in previous equation, Execution time = clock cycle time x number of instrs x avg CPI If a 2 GHz processor graduates an instruction every third cycle, how many instructions are there in a program that runs for 10 seconds? 4

5 Power Consumption Dyn power α activity x capacitance x voltage 2 x frequency Capacitance per transistor and voltage are decreasing, but number of transistors and frequency are increasing at a faster rate Leakage power is also rising and will soon match dynamic power Power consumption is already around 100W in some high-performance processors today 5

6 Basic MIPS Instructions lw \$t1, 16(\$t2) add \$t3, \$t1, \$t2 addi \$t3, \$t3, 16 sw \$t3, 16(\$t2) beq \$t1, \$t2, 16 blt is implemented as slt and bne j 64 jr \$t1 sll \$t1, \$t1, 2 Convert to assembly: while (save[i] == k) i += 1; i and k are in \$s3 and \$s5 and base of array save[] is in \$s6 Loop: sll \$t1, \$s3, 2 add \$t1, \$t1, \$s6 lw \$t0, 0(\$t1) bne \$t0, \$s5, Exit addi \$s3, \$s3, 1 j Loop Exit: 6

7 Registers The 32 MIPS registers are partitioned as follows: Register 0 : \$zero always stores the constant 0 Regs 2-3 : \$v0, \$v1 return values of a procedure Regs 4-7 : \$a0-\$a3 input arguments to a procedure Regs 8-15 : \$t0-\$t7 temporaries Regs 16-23: \$s0-\$s7 variables Regs 24-25: \$t8-\$t9 more temporaries Reg 28 : \$gp global pointer Reg 29 : \$sp stack pointer Reg 30 : \$fp frame pointer Reg 31 : \$ra return address 7

8 Memory Organization Stack Proc A s values High address Dynamic data (heap) Static data (globals) Text (instructions) Proc B s values \$gp Proc C s values Stack grows this way \$fp \$sp Low address 8

9 Procedure Calls/Returns proca (int i) { int j; j = ; call procb(j); = j; } proca: \$s0 = # value of j \$t0 = # some tempval \$a0 = \$s0 # the argument jal procb = \$v0 procb (int j) { int k; = j; k = ; return k; } procb: \$t0 = # some tempval = \$a0 # using the argument \$s0 = # value of k \$v0 = \$s0; jr \$ra 9

10 Saves and Restores Caller saves: \$ra, \$a0, \$t0, \$fp (if reqd) As every element is saved on stack, the stack pointer is decremented Callee saves: \$s0 proca: \$s0 = # value of j \$t0 = # some tempval \$a0 = \$s0 # the argument jal procb = \$v0 procb: \$t0 = # some tempval = \$a0 # using the argument \$s0 = # value of k \$v0 = \$s0; jr \$ra 10

11 Example 2 int fact (int n) { if (n < 1) return (1); else return (n * fact(n-1)); } Notes: The caller saves \$a0 and \$ra in its stack space. Temps are never saved. fact: addi \$sp, \$sp, -8 sw \$ra, 4(\$sp) sw \$a0, 0(\$sp) slti \$t0, \$a0, 1 beq \$t0, \$zero, L1 addi \$v0, \$zero, 1 addi \$sp, \$sp, 8 jr \$ra L1: addi \$a0, \$a0, -1 jal fact lw \$a0, 0(\$sp) lw \$ra, 4(\$sp) addi \$sp, \$sp, 8 mul \$v0, \$a0, \$v0 jr \$ra 11

12 Recap Numeric Representations Decimal = 3 x x 10 0 Binary = 1 x x x 2 0 Hexadecimal (compact representation) 0x 23 or 23 hex = 2 x x (decimal) 0-9, a-f (hex) Dec Binary Hex Dec Binary Hex Dec Binary Hex a b Dec Binary Hex c d e f 12

13 2 s Complement two = 0 ten two = 1 ten two = two = two = -(2 31 1) two = -(2 31 2) two = two = -1 Note that the sum of a number x and its inverted representation x always equals a string of 1s (-1). x + x = -1 x + 1 = -x hence, can compute the negative of a number by -x = x + 1 inverting all bits and adding 1 This format can directly undergo addition without any conversions! Each number represents the quantity x x x x x

14 Multiplication Example Multiplicand 1000 ten Multiplier x 1001 ten Product ten In every step multiplicand is shifted next bit of multiplier is examined (also a shifting step) if this bit is 1, shifted multiplicand is added to the product 14

15 Division 1001 ten Quotient Divisor 1000 ten ten Dividend ten Remainder At every step, shift divisor right and compare it with current dividend if divisor is larger, shift 0 as the next bit of the quotient if divisor is smaller, subtract to get new dividend and shift 1 as the next bit of the quotient 15

16 Division 1001 ten Quotient Divisor 1000 ten ten Dividend Quo: At every step, shift divisor right and compare it with current dividend if divisor is larger, shift 0 as the next bit of the quotient if divisor is smaller, subtract to get new dividend and shift 1 as the next bit of the quotient 16

17 Divide Example Divide 7 ten ( two ) by 2 ten (0010 two ) Iter Step Quot Divisor Remainder 0 Initial values Rem = Rem Div Rem < 0 +Div, shift 0 into Q Shift Div right Same steps as Same steps as Rem = Rem Div Rem >= 0 shift 1 into Q Shift Div right Same steps as

18 Binary FP Numbers decimal =? Binary 20 decimal = binary 0.45 x 2 = 0.9 (not greater than 1, first bit after binary point is 0) 0.90 x 2 = 1.8 (greater than 1, second bit is 1, subtract 1 from 1.8) 0.80 x 2 = 1.6 (greater than 1, third bit is 1, subtract 1 from 1.6) 0.60 x 2 = 1.2 (greater than 1, fourth bit is 1, subtract 1 from 1.2) 0.20 x 2 = 0.4 (less than 1, fifth bit is 0) 0.40 x 2 = 0.8 (less than 1, sixth bit is 0) 0.80 x 2 = 1.6 (greater than 1, seventh bit is 1, subtract 1 from 1.6) and the pattern repeats Normalized form = x

19 IEEE 754 Format Final representation: (-1) S x (1 + Fraction) x 2 (Exponent Bias) Represent ten in single and double-precision formats Single: ( ) Double: ( ) What decimal number is represented by the following single-precision number?

20 FP Addition Binary Example Consider the following binary example x x 2 3 Convert to the larger exponent: x x 2 3 Add x 2 3 Normalize x 2 3 Check for overflow/underflow Round Re-normalize IEEE 754 format:

21 Boolean Algebra A + B = A. B A. B = A + B A B C E Any truth table can be expressed as a sum of products (A. B. C) + (A. C. B) + (C. B. A) Can also use product of sums Any equation can be implemented with an array of ANDs, followed by an array of ORs 21

22 Adder Implementations Ripple-Carry adder each 1-bit adder feeds its carry-out to next stage simple design, but we must wait for the carry to propagate thru all bits Carry-Lookahead adder each bit can be represented by an equation that only involves input bits (a i, b i ) and initial carry-in (c 0 ) -- this is a complex equation, so it s broken into sub-parts For bits a i, b i,, and c i, a carry is generated if a i.b i = 1 and a carry is propagated if a i + b i = 1 C i+1 = g i + p i. C i Similarly, compute these values for a block of 4 bits, then for a block of 16 bits, then for a block of 64 bits.finally, the carry-out for the 64 th bit is represented by an equation such as this: C 4 = G 3 + G 2.P 3 + G 1.P 2.P 3 + G 0.P 1.P 2.P 3 + C 0.P 0.P 1.P 2.P 3 Each of the sub-terms is also a similar expression 22

23 32-bit ALU Source: H&P textbook 23

24 Control Lines What are the values of the control lines and what operations do they correspond to? Ai Bn Op AND OR Add Sub SLT NOR Source: H&P textbook 24

25 State Transition Table Problem description: A traffic light with only green and red; either the North-South road has green or the East-West road has green (both can t be red); there are detectors on the roads to indicate if a car is on the road; the lights are updated every 30 seconds; a light must change only if a car is waiting on the other road State Transition Table: CurrState InputEW InputNS NextState=Output N 0 0 N N 0 1 N N 1 0 E N 1 1 E E 0 0 E E 0 1 N E 1 0 E E 1 1 N 25

26 Midterm Question Thermostat can be OFF, HEAT, COOL Two input sensors Ext temp within 5 degrees of desired temp OFF Int temp within 1 degree of desired temp no change Int temp < desired temp -1 HEAT Int temp > desired temp +1 COOL 26

27 Title 27

### 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

### 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

### 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

### 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

### Architecture II. Computer Systems Laboratory Sungkyunkwan University

MIPS Instruction ti Set Architecture II Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Making Decisions (1) Conditional operations Branch to a

### Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology

Computer Organization MIPS Architecture Department of Computer Science Missouri University of Science & Technology hurson@mst.edu Computer Organization Note, this unit will be covered in three lectures.

### Number Systems and Computer Arithmetic

Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction R-format I-format... integer data number text

### Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine

Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction

### Computer Architecture. Chapter 3: Arithmetic for Computers

182.092 Computer Architecture Chapter 3: Arithmetic for Computers Adapted from Computer Organization and Design, 4 th Edition, Patterson & Hennessy, 2008, Morgan Kaufmann Publishers and Mary Jane Irwin

### ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5

ENCM 369 Winter 2013: Reference Material for Midterm #2 page 1 of 5 MIPS/SPIM General Purpose Registers Powers of Two 0 \$zero all bits are zero 16 \$s0 local variable 1 \$at assembler temporary 17 \$s1 local

### MIPS%Assembly% E155%

MIPS%Assembly% E155% Outline MIPS Architecture ISA Instruction types Machine codes Procedure call Stack 2 The MIPS Register Set Name Register Number Usage \$0 0 the constant value 0 \$at 1 assembler temporary

### MIPS Assembly Programming

COMP 212 Computer Organization & Architecture COMP 212 Fall 2008 Lecture 8 Cache & Disk System Review MIPS Assembly Programming Comp 212 Computer Org & Arch 1 Z. Li, 2008 Comp 212 Computer Org & Arch 2

### COMP 303 Computer Architecture Lecture 6

COMP 303 Computer Architecture Lecture 6 MULTIPLY (unsigned) Paper and pencil example (unsigned): Multiplicand 1000 = 8 Multiplier x 1001 = 9 1000 0000 0000 1000 Product 01001000 = 72 n bits x n bits =

### Grading: 3 pts each part. If answer is correct but uses more instructions, 1 pt off. Wrong answer 3pts off.

Department of Electrical and Computer Engineering University of Wisconsin Madison ECE 552 Introductions to Computer Architecture Homework #2 (Suggested Solution) 1. (10 points) MIPS and C program translations

### 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

### Lecture 2: Performance

Lecture 2: Performance Today s topics: Technology wrap-up Performance trends and equations Reminders: YouTube videos, canvas, and class webpage: http://www.cs.utah.edu/~rajeev/cs3810/ 1 Important Trends

### Compiling Techniques

Lecture 10: An Introduction to MIPS assembly 18 October 2016 Table of contents 1 Overview 2 3 Assembly program template.data Data segment: constant and variable definitions go here (including statically

### SPIM Instruction Set

SPIM Instruction Set This document gives an overview of the more common instructions used in the SPIM simulator. Overview The SPIM simulator implements the full MIPS instruction set, as well as a large

### ECE232: Hardware Organization and Design. Computer Organization - Previously covered

ECE232: Hardware Organization and Design Part 6: MIPS Instructions II http://www.ecs.umass.edu/ece/ece232/ Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Computer Organization

### All instructions have 3 operands Operand order is fixed (destination first)

Instruction Set Architecture for MIPS Processors Overview Dr. Arjan Durresi Louisiana State University Baton Rouge, LA 70803 durresi@csc.lsu.edu These slides are available at: http://www.csc.lsu.edu/~durresi/_07/

### Programming at different levels

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014 EMY MNEMONIC MACHINE LANGUAGE PROGRAMMING EXAMPLES Programming at different levels CS1114 Mathematical Problem : a = b + c CS2214 CS2214 The C-like

### 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

### Solutions for Chapter 2 Exercises

Solutions for Chapter 2 Exercises 1 Solutions for Chapter 2 Exercises 2.2 By lookup using the table in Figure 2.5 on page 62, 7fff fffa hex = 0111 1111 1111 1111 1111 1111 1111 1010 two = 2,147,483,642

### Numbers: positional notation. CS61C Machine Structures. Faux Midterm Review Jaein Jeong Cheng Tien Ee. www-inst.eecs.berkeley.

CS 61C Faux Midterm Review (1) CS61C Machine Structures Faux Midterm Review 2002-09-29 Jaein Jeong Cheng Tien Ee www-inst.eecs.berkeley.edu/~cs61c/ Numbers: positional notation Number Base B B symbols

### 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

### Arithmetic. Chapter 3 Computer Organization and Design

Arithmetic Chapter 3 Computer Organization and Design Addition Addition is similar to decimals 0000 0111 + 0000 0101 = 0000 1100 Subtraction (negate) 0000 0111 + 1111 1011 = 0000 0010 Over(under)flow For

### Tailoring the 32-Bit ALU to MIPS

Tailoring the 32-Bit ALU to MIPS MIPS ALU extensions Overflow detection: Carry into MSB XOR Carry out of MSB Branch instructions Shift instructions Slt instruction Immediate instructions ALU performance

### October 24. Five Execution Steps

October 24 Programming problems? Read Section 6.1 for November 5 How instructions execute Test Preview Ask Questions! 10/24/2001 Comp 120 Fall 2001 1 Five Execution Steps Instruction Fetch Instruction

### CS3350B Computer Architecture

CS3350B Computer Architecture Winter 2015 Lecture 4.1: MIPS ISA: Introduction Marc Moreno Maza www.csd.uwo.ca/courses/cs3350b [Adapted d from lectures on Computer Organization and Design, Patterson & Hennessy,

### CO Computer Architecture and Programming Languages CAPL. Lecture 13 & 14

CO20-320241 Computer Architecture and Programming Languages CAPL Lecture 13 & 14 Dr. Kinga Lipskoch Fall 2017 Frame Pointer (1) The stack is also used to store variables that are local to function, but

### CS 61C: Great Ideas in Computer Architecture MIPS Instruction Formats

CS 61C: Great Ideas in Computer Architecture MIPS Instruction Formats Instructors: Vladimir Stojanovic and Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/sp16 1 Machine Interpretation Levels of Representation/Interpretation

### Lecture 6 Decision + Shift + I/O

Lecture 6 Decision + Shift + I/O Instructions so far MIPS C Program add, sub, addi, multi, div lw \$t0,12(\$s0) sw \$t0, 12(\$s0) beq \$s0, \$s1, L1 bne \$s0, \$s1, L1 j L1 (unconditional branch) slt reg1,reg2,reg3

### Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008 MIPS Intro II Lect 10 Feb 15, 2008 Adapted from slides developed for: Mary J. Irwin PSU CSE331 Dave Patterson s UCB CS152 M230 L10.1

### Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood

### HW2 solutions You did this for Lab sbn temp, temp,.+1 # temp = 0; sbn temp, b,.+1 # temp = -b; sbn a, temp,.+1 # a = a (-b) = a + b;

HW2 solutions 3.10 Pseuodinstructions What is accomplished Minimum sequence of Mips Move \$t5, \$t3 \$t5=\$t3 Add \$t5, \$t3, \$0 Clear \$t5 \$t5=0 Xor \$t5, \$t5, \$t5 Li \$t5, small \$t5=small Addi \$t5, \$0, small

### ECE Exam I February 19 th, :00 pm 4:25pm

ECE 3056 Exam I February 19 th, 2015 3:00 pm 4:25pm 1. The exam is closed, notes, closed text, and no calculators. 2. The Georgia Tech Honor Code governs this examination. 3. There are 4 questions and

### 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 =

### Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions

Outline EEL-4713 Computer Architecture Multipliers and shifters Multiplication and shift registers Chapter 3, section 3.4 Next lecture Division, floating-point 3.5 3.6 EEL-4713 Ann Gordon-Ross.1 EEL-4713

### Chapter 3 Arithmetic for Computers

Chapter 3 Arithmetic for Computers 1 Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: Implementing the Architecture operation

### CS/COE 0447 Example Problems for Exam 2 Spring 2011

CS/COE 0447 Example Problems for Exam 2 Spring 2011 1) Show the steps to multiply the 4-bit numbers 3 and 5 with the fast shift-add multipler. Use the table below. List the multiplicand (M) and product

### Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

Computer Science and Engineering 331 Midterm Examination #1 Fall 2000 Name: Solutions S.S.#: 1 41 2 13 3 18 4 28 Total 100 Instructions: This exam contains 4 questions. It is closed book and notes. Calculators

### MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

MIPS ISA and MIPS Assembly CS301 Prof. Szajda Administrative HW #2 due Wednesday (9/11) at 5pm Lab #2 due Friday (9/13) 1:30pm Read Appendix B5, B6, B.9 and Chapter 2.5-2.9 (if you have not already done

### CS 61C: Great Ideas in Computer Architecture Strings and Func.ons. Anything can be represented as a number, i.e., data or instruc\ons

CS 61C: Great Ideas in Computer Architecture Strings and Func.ons Instructor: Krste Asanovic, Randy H. Katz hdp://inst.eecs.berkeley.edu/~cs61c/sp12 Fall 2012 - - Lecture #7 1 New- School Machine Structures

### CS3350B Computer Architecture MIPS Procedures and Compilation

CS3350B Computer Architecture MIPS Procedures and Compilation Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada

### COMP MIPS instructions 2 Feb. 8, f = g + h i;

Register names (save, temporary, zero) From what I have said up to now, you will have the impression that you are free to use any of the 32 registers (\$0,..., \$31) in any instruction. This is not so, however.

### Fast Arithmetic. Philipp Koehn. 19 October 2016

Fast Arithmetic Philipp Koehn 19 October 2016 1 arithmetic Addition (Immediate) 2 Load immediately one number (s0 = 2) li \$s0, 2 Add 4 (\$s1 = \$s0 + 4 = 6) addi \$s1, \$s0, 4 Subtract 3 (\$s2 = \$s1-3 = 3)

### Assembly Language Programming

Assembly Language Programming Remember the programmer shown in our first lecture? Originally, computers were programmed manually. After a while, scientists began to consider ways to accelerate and facilitate

### Inequalities in MIPS (2/4) Inequalities in MIPS (1/4) Inequalities in MIPS (4/4) Inequalities in MIPS (3/4) UCB CS61C : Machine Structures

CS61C L8 Introduction to MIPS : Decisions II & Procedures I (1) Instructor Paul Pearce inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures http://www.xkcd.org/627/ Lecture 8 Decisions & and Introduction

### Announcements. EE108B Lecture MIPS Assembly Language III. MIPS Machine Instruction Review: Instruction Format Summary

Announcements EE108B Lecture MIPS Assembly Language III Christos Kozyrakis Stanford University http://eeclass.stanford.edu/ee108b PA1 available, due on Thursday 2/8 Work on you own (no groups) Homework

### Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

Computer Science 324 Computer Architecture Mount Holyoke College Fall 2009 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture. Idea:

### Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures

Homework 3 Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) 1 CSCI 402: Computer Architectures Arithmetic for Computers (2) Fengguang Song Department

### Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats

Today s Lecture Homework #2 Midterm I Feb 22 (in class closed book) MIPS Assembly Language Computer Science 14 Lecture 6 Outline Assembly Programming Reading Chapter 2, Appendix B 2 Review: A Program Review:

### ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

### 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

### 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

### Part I: Translating & Starting a Program: Compiler, Linker, Assembler, Loader. Lecture 4

Part I: a Program: Compiler, Linker, Assembler, Loader Lecture 4 Program Translation Hierarchy C program Com piler Assem bly language program Assem bler Object: Machine language module Object: Library

### CS 4200/5200 Computer Architecture I

CS 4200/5200 Computer Architecture I MIPS Instruction Set Architecture Dr. Xiaobo Zhou Department of Computer Science CS420/520 Lec3.1 UC. Colorado Springs Adapted from UCB97 & UCB03 Review: Organizational

### Module 2: Computer Arithmetic

Module 2: Computer Arithmetic 1 B O O K : C O M P U T E R O R G A N I Z A T I O N A N D D E S I G N, 3 E D, D A V I D L. P A T T E R S O N A N D J O H N L. H A N N E S S Y, M O R G A N K A U F M A N N

### Midterm. CS64 Spring Midterm Exam

Midterm LAST NAME FIRST NAME PERM Number Instructions Please turn off all pagers, cell phones and beepers. Remove all hats & headphones. Place your backpacks, laptops and jackets at the front. Sit in every

### CO Computer Architecture and Programming Languages CAPL. Lecture 15

CO20-320241 Computer Architecture and Programming Languages CAPL Lecture 15 Dr. Kinga Lipskoch Fall 2017 How to Compute a Binary Float Decimal fraction: 8.703125 Integral part: 8 1000 Fraction part: 0.703125

### Assembly Language Programming. CPSC 252 Computer Organization Ellen Walker, Hiram College

Assembly Language Programming CPSC 252 Computer Organization Ellen Walker, Hiram College Instruction Set Design Complex and powerful enough to enable any computation Simplicity of equipment MIPS Microprocessor

### 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

### ECE 2035 Programming HW/SW Systems Spring problems, 7 pages Exam One Solutions 4 February 2013

Problem 1 (3 parts, 30 points) Code Fragments Part A (5 points) Write a MIPS code fragment that branches to label Target when register \$1 is less than or equal to register \$2. You may use only two instructions.

### Chapter 5: Computer Arithmetic

Slide 1/29 Learning Objectives Computer Fundamentals: Pradeep K. Sinha & Priti Sinha In this chapter you will learn about: Reasons for using binary instead of decimal numbers Basic arithmetic operations

### Chapter 4 Section 2 Operations on Decimals

Chapter 4 Section 2 Operations on Decimals Addition and subtraction of decimals To add decimals, write the numbers so that the decimal points are on a vertical line. Add as you would with whole numbers.

### 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

### UCB CS61C : Machine Structures

inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 10 Introduction to MIPS Procedures I Sr Lecturer SOE Dan Garcia 2014-02-14 If cars broadcast their speeds to other vehicles (and the

### Chapter 4. The Processor. Computer Architecture and IC Design Lab

Chapter 4 The Processor Introduction CPU performance factors CPI Clock Cycle Time Instruction count Determined by ISA and compiler CPI and Cycle time Determined by CPU hardware We will examine two MIPS

### Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture. Idea:

### CS 61C: Great Ideas in Computer Architecture Introduction to Assembly Language and RISC-V Instruction Set Architecture

CS 61C: Great Ideas in Computer Architecture Introduction to Assembly Language and RISC-V Instruction Set Architecture Instructors: Krste Asanović & Randy H. Katz http://inst.eecs.berkeley.edu/~cs61c 9/7/17

### 2. dead code elimination (declaration and initialization of z) 3. common subexpression elimination (temp1 = j + g + h)

Problem 1 (20 points) Compilation Perform at least five standard compiler optimizations on the following C code fragment by writing the optimized version (in C) to the right. Assume f is a pure function

### Assembly Programming

Designing Computer Systems Assembly Programming 08:34:48 PM 23 August 2016 AP-1 Scott & Linda Wills Designing Computer Systems Assembly Programming In the early days of computers, assembly programming

### ICS 233 COMPUTER ARCHITECTURE. MIPS Processor Design Multicycle Implementation

ICS 233 COMPUTER ARCHITECTURE MIPS Processor Design Multicycle Implementation Lecture 23 1 Add immediate unsigned Subtract unsigned And And immediate Or Or immediate Nor Shift left logical Shift right

### 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

### Lecture 7: MIPS Functions Part 2. Nested Function Calls. Lecture 7: Character and String Operations. SPIM Syscalls. Recursive Functions

Part Part Part What if we need to call a function inside of a function? Will this work? int twofun(int a, int b) { int res; res = addfun(a, b) a / ; return res; } twofun: addi \$sp, \$sp, -4 sw \$s0, 0(\$sp)

### Octal & Hexadecimal Number Systems. Digital Electronics

Octal & Hexadecimal Number Systems Digital Electronics What, More Number Systems? Why do we need more number systems? Humans understand decimal Check out my ten digits! Digital electronics (computers)

### Problem maximum score 1 35pts 2 22pts 3 23pts 4 15pts Total 95pts

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Sciences CS61c Summer 2001 Woojin Yu Midterm Exam This is a closed-book exam. No calculators

### Chapter 3 Arithmetic for Computers (Part 2)

Department of Electr rical Eng ineering, Chapter 3 Arithmetic for Computers (Part 2) 王振傑 (Chen-Chieh Wang) ccwang@mail.ee.ncku.edu.tw ncku edu Depar rtment of Electr rical Eng ineering, Feng-Chia Unive

### Chapter 2. Instruction Set Architecture (ISA)

Chapter 2 Instruction Set Architecture (ISA) MIPS arithmetic Design Principle: simplicity favors regularity. Why? Of course this complicates some things... C code: A = B + C + D; E = F - A; MIPS code:

### Chapter 2. Instructions: Language of the Computer

Chapter 2 Instructions: Language g of the Computer Outlines Introduction to MIPS machine Operations of the Computer HW Operands of the Computer HW Representing instructions in the Computer Logical Operations

### Lab 4 : MIPS Function Calls

Lab 4 : 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 objective of this lab

### Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21

2.9 Communication with People: Byte Data & Constants Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21 32: space 33:! 34: 35: #...

### Instruction Set Architecture (Contd)

Instruction Set Architecture (Contd) Lecture 3 (Chapter 2) EEC170 FQ 2005 Review: MIPS Architecture Good example of RISC processor: Reduced Instruction-Set Computer RISC really a misnomer: architecture

### ECE 154A Introduction to. Fall 2012

ECE 154A Introduction to Computer Architecture Fall 2012 Dmitri Strukov Lecture 4: Arithmetic and Data Transfer Instructions Agenda Review of last lecture Logic and shift instructions Load/store instructionsi

### The Single Cycle Processor

EECS 322 Computer Architecture The Single Cycle Processor Instructor: Francis G. Wolff wolff@eecs.cwru.edu Case Western Reserve University This presentation uses powerpoint animation: please viewshow CWRU

### ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Wednesday, Oct. 19, 2011 (30 points)

ECE 473 Computer Architecture and Organization Lab 4: MIPS Assembly Programming Due: Wednesday, Oct. 19, 2011 (30 points) Objectives: Get familiar with MIPS instructions Assemble, execute and debug MIPS

### CSE A215 Assembly Language Programming for Engineers

CSE A215 Assembly Language Programming for Engineers Lecture 7 MIPS vs. ARM (COD Chapter 2 and Exam #1 Review) October 12, 2012 Sam Siewert Comparison of MIPS32 and ARM Instruction Formats and Addressing

### Today s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA.

Today s topics CS/COE1541: Introduction to Computer Architecture MIPS operations and operands MIPS registers Memory view Instruction encoding A Review of MIPS ISA Sangyeun Cho Arithmetic operations Logic

### 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)

### MIPS Procedure Calls. Lecture 6 CS301

MIPS Procedure Calls Lecture 6 CS301 Function Call Steps Place parameters in accessible location Transfer control to function Acquire storage for procedure variables Perform calculations in function Place

### Forecast. Instructions (354 Review) Basics. Basics. Instruction set architecture (ISA) is its vocabulary. Instructions are the words of a computer

Instructions (354 Review) Forecast Instructions are the words of a computer Instruction set architecture (ISA) is its vocabulary With a few other things, this defines the interface of computers But implementations

### 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

### MIPS (SPIM) Assembler Syntax

MIPS (SPIM) Assembler Syntax Comments begin with # Everything from # to the end of the line is ignored Identifiers are a sequence of alphanumeric characters, underbars (_), and dots () that do not begin

### Orange Coast College. Business Division. Computer Science Department CS 116- Computer Architecture. The Instructions

Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture The Instructions 1 1 Topics: Assembly language, assemblers MIPS R2000 Assembly language Instruction set

### Lecture 3: The Instruction Set Architecture (cont.)

Lecture 3: The Instruction Set Architecture (cont.) COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David August 1 Review: Instructions Computers process information

### Concocting an Instruction Set

Concocting an Instruction Set Nerd Chef at work. move flour,bowl add milk,bowl add egg,bowl move bowl,mixer rotate mixer... Read: Chapter 2.1-2.7 L03 Instruction Set 1 A General-Purpose Computer The von

### Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

Chapter 03: Computer Arithmetic Lesson 09: Arithmetic using floating point numbers Objective To understand arithmetic operations in case of floating point numbers 2 Multiplication of Floating Point Numbers

### MIPS Reference Guide

MIPS Reference Guide Free at PushingButtons.net 2 Table of Contents I. Data Registers 3 II. Instruction Register Formats 4 III. MIPS Instruction Set 5 IV. MIPS Instruction Set (Extended) 6 V. SPIM Programming