2B 52 AB CA 3E A1 +29 A B C. CS120 Fall 2018 Final Prep and super secret quiz 9

Similar documents
2) Using the same instruction set for the TinyProc2, convert the following hex values to assembly language: x0f

CS 230 Practice Final Exam & Actual Take-home Question. Part I: Assembly and Machine Languages (22 pts)

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

ECE 30 Introduction to Computer Engineering

Lecture 5: Procedure Calls

MIPS Assembly Programming

CSE 378 Midterm 2/12/10 Sample Solution

CSE Lecture In Class Example Handout

Problem 3: Theoretical Questions: Complete the midterm exam taken from a previous year attached at the end of the assignment.

CS 61c: Great Ideas in Computer Architecture

EE 361 University of Hawaii Fall

MIPS%Assembly% E155%

Lecture 5: Procedure Calls

Topic Notes: MIPS Instruction Set Architecture

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions

Format. 10 multiple choice 8 points each. 1 short answer 20 points. Same basic principals as the midterm

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

CDA3100 Midterm Exam, Summer 2013

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

Mips Code Examples Peter Rounce

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

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

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

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 3 2/8/2018

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

ECE331: Hardware Organization and Design

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

ECE232: Hardware Organization and Design

Signature: 1. (10 points) Basic Microcontroller Concepts

CS/COE 0447 Example Problems for Exam 2 Fall 2010

ECE550 PRACTICE Midterm

MIPS Functions and Instruction Formats

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes

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

MIPS Functions and the Runtime Stack

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 5 2/22/2018

CSE 378 Midterm Sample Solution 2/11/11

Lectures 3-4: MIPS instructions

October 24. Five Execution Steps

COMPUTER ORGANIZATION AND DESIGN

Programming the processor

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

Control Instructions

McGill University Faculty of Engineering FINAL EXAMINATION Fall 2007 (DEC 2007)

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 19 September 2012

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI.

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

Computer Architecture I Midterm I

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

University of California at Santa Barbara. ECE 154A Introduction to Computer Architecture. Quiz #1. October 30 th, Name (Last, First)

Chapter 2. Instructions:

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

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

1/26/2014. Previously. CSE 2021: Computer Organization. The Load/Store Family (1) Memory Organization. The Load/Store Family (2)

Lecture 7: Examples, MARS, Arithmetic

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

COMP2611: Computer Organization MIPS function and recursion

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

CSE 378 Final Exam 3/14/11 Sample Solution

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

ECE232: Hardware Organization and Design

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

MIPS function continued

Compiling Code, Procedures and Stacks

CENG3420 Lecture 03 Review

Assignment 1 solutions

ECE260: Fundamentals of Computer Engineering


MIPS Assembly (Functions)

Cache Organizations for Multi-cores

University of California, Berkeley College of Engineering

The plot thickens. Some MIPS instructions you can write cannot be translated to a 32-bit number

Common Problems on Homework

Instructor: Randy H. Katz hap://inst.eecs.berkeley.edu/~cs61c/fa13. Fall Lecture #7. Warehouse Scale Computer

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

University of California, Berkeley College of Engineering

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed.

Lecture 7 Logic Simplification

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

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

The plot thickens. Some MIPS instructions you can write cannot be translated to a 32-bit number

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total

Chapter 2A Instructions: Language of the Computer

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

Implement a C language function that computes the factorial of a number, recursively, according to the following prototype:

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

Lecture 4: MIPS Instruction Set

Chapter 2. Instructions: Language of the Computer. HW#1: 1.3 all, 1.4 all, 1.6.1, , , , , and Due date: one week.

CS3350B Computer Architecture Quiz 3 March 15, 2018

ECE 30 Introduction to Computer Engineering

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

Previously. CSE 2021: Computer Organization. Memory Organization. The Load/Store Family (1) 5/26/2011. Used to transfer data to/from DRAM.

Solutions for Chapter 2 Exercises

OPEN BOOK, OPEN NOTES. NO COMPUTERS, OR SOLVING PROBLEMS DIRECTLY USING CALCULATORS.

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

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

CS 61c: Great Ideas in Computer Architecture

ICS DEPARTMENT ICS 233 COMPUTER ARCHITECTURE & ASSEMBLY LANGUAGE. Midterm Exam. First Semester (141) Time: 1:00-3:30 PM. Student Name : _KEY

CS/COE1541: Introduction to Computer Architecture

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 21 October 2016

Transcription:

S2 Fall 28 Final Prep and super secret quiz 9 ) onvert 8-bit (2-digit) 2 s complement hex values: 4-29 inary: Hex: x29 2) onvert 8-bit 2 s complement hex to decimal: x3 inary: xe5 Decimal: 58 Note 3*6+ = 58 3) dd these hex numbers. Stay in hex! 9 +2 3E +4 55 +56 inary 29: Flip: + Hex: xe3 inary: Flip: +: Final binary is 27, so orig decimal is -27 +29 2 52 4) What are possible number ranges for a 7-bit integers for Unsigned? 2 s complement? Unsigned: to 27, 2 s comp is -64 to 63 5) reate a truth table for the following circuit. ND 6) ou have a circuit with inputs,, and. Design a circuit that produces if there are an odd number of s on the inputs.!! +!! +!! + Not much you can do with the Karnaugh map, but you could build the circuit with two XOR gates XOR XOR

7) Simplify the oolean equation = (+!)(+)() ((+!))(+)() ()(+)() ( + )() ((+)) ()() < simplified final version 8) ou need a 2-input OR gate, but you only have an ND gate and some inverters. Use your ND gate and inverters to make an OR gate. Final version OR OR NOT NOT NOR NOT OR gate with two inverters is the same as an OR. This lets us bubble push, or into an ND with inverted inputs 9) Show the truth table for the following finite state machine. S S is the current state, NS NS is the next state. The input is T, T S S NS NS x x x x ) onstruct a Karnaugh map, and show the simplified circuit for the following truth table. x!! + x NOR ND OR

) ou have a JL instruction at location x42488. Immediately after executing the JL, what value is in register $R? x42488 + 4 > x4248 2) Register $s is a POINTER to the start of an array of integers. ll values in the array are greater than zero, and the array is terminated by a zero. Write code and MIPS code to compute the sum of all the values in the array, leaving the sum in register $s. Version data[] = 3, 5, 99, ; int *s = data; // our code follows here int s = ; for (int i = ; s[i]!= ; ++i) s = s + s[i]; // lternate move pointers int s = ; while (*s!= ) s = s + *s; ++s; 3) Write MIPS assembly to add 8 to a value (passed as a pointer). The code looks like this. This is a subroutine. void add_eight(int *x) if (*x == ) *x = 8; else *x = *x + 5; MIPS Version la $s, data # s points to array # our code follows here # Move pointers # variation li $s, loop: lw $t, ($s) # Similar to top li $s, li $t, loop: # pointer t2 is # s + t*4 sll $t2, $t, 2 add $t2, $s, $t2 lw $t, ($t2) beq $t, $, done add $s, $s, $t # Increment i addi $t, $t, j loop 4) Write MIPS assembly for sub, a subroutine that calls two other subroutines. The code looks like this. This is also a subroutine. sub2 and sub3 are in a library. int sub(int a, int b) sub2(a); sub3(b); return 6; beq $t, $, done add $s, $s, $t # Move pointer add $s, $s, 4 j loop SEE NEXT PGE. The key has lots of comments, which you don t have to do for the exam.

void add_eight(int *x) if (*x == ) *x = 8; else *x = *x + 5; int sub(int a, int b) sub2(a); sub3(b); return 6; add_eight: # Get the pointer to X lw $t, ($sp) # Get the value indicated lw $t, ($t) # If statement here. check # if not equal bne $t, $, else_part # Use t, and pointer to change # value to 8 li $t, 8 sw $t, ($t) # IMPORTNT. Must jump past the # next few lines, to not do # the else section too! j done else_part: addi $t, $t, 5 sw $t, ($t) jr $ra # In this code, because there s no # jal call, it s OK to not save # R. If you save it cool, that s # not a bad thing to do but it s # not absolutely required sub: # Push R sw $ra, ($sp) # Get the lw $t, 4($sp) # Push on stack sw $t, ($sp) # all sub2 jal sub2 # Pop off stack # Get lw $t, 8($sp) # Push on stack sw $t, ($sp) # all sub3 jal sub3 # Pop off stack # Restore R lw $ra, ($sp) Return to whoever called us jr $ra

5) When a processor is not pipelined, different instructions might take different numbers of cycles. If a LW takes 5 cycles, an DD takes 4, and a RNH takes 2, and you have a program that is 5% LW instructions, 2% DD instructions, and 3% branch instructions, what is the average PI (cycles per instruction)? 5*.5 + 4*.2 + 2*.3 = 3.9 cycles per instruction, average 6) ou have a non-pipelined processor, with all instructions taking five steps, as shown below. The time required in terms of cycles is shown. Fetch 5 What s the PI? Decode 2 Execute 3 Memory 4 Write Reg 5 cycles per instruction. 5+2+3+4+ = 5 7) If you pipeline the microprocessor, how many cycles would a single instruction take? Slowest link is fetch, 5 cycles. 5 stages, 5 cycles each, 25 cycles 8) What are the effective average PI and IP of the pipelined processor (assuming no stalls, or pipeline flushing due to branches). PI = 5, IP = /5. 9) Name two types of hazards you might see on a pipelined microprocessor ontrol hazard (e.g., a jump needs a NOP after it), and data hazard (result stored in one register not available immediately) 2) Modify the code below so that it could run faster on a pipelined microprocessor. add $a, $a3, $a4 add $a, $a, $a lui $a3, 58 Swap last two instructions. $a in first instruction is not finished when second instruction that uses $a starts 2) onus question. Have you filled out the SOOT survey (secret answer is yes ) The final will ask what is the secret answer to the secret question, and you should say yes