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.

Similar documents
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.

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

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 Instructor: Steve Norman

Winter 2006 FINAL EXAMINATION Auxiliary Gymnasium Tuesday, April 18 7:00pm to 10:00pm

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

Winter 2009 FINAL EXAMINATION Location: Engineering A Block, Room 201 Saturday, April 25 noon to 3:00pm

Winter 2002 FINAL EXAMINATION

University of Calgary Department of Electrical and Computer Engineering ENCM 339 Lecture Section 01 Instructor: Steve Norman

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

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

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

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

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

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

ECE 30 Introduction to Computer Engineering

Slide Set 1 (corrected)

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

University of Calgary Department of Electrical and Computer Engineering ENCM 335 Instructor: Steve Norman

Winter 2013 MIDTERM TEST #2 Wednesday, March 20 7:00pm to 8:15pm. Please do not write your U of C ID number on this cover page.

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

Chapter 2. Instructions:

ENCM 369 Winter 2019 Lab 6 for the Week of February 25

Lecture 5: Procedure Calls

The University of Calgary. ENCM 339 Programming Fundamentals Fall 2016

Chapter 3. Instructions:

ENEL 353: Digital Circuits Midterm Examination

EE 361 University of Hawaii Fall

Homework 4 - Solutions (Floating point representation, Performance, Recursion and Stacks) Maximum points: 80 points

ENCM 369 Winter 2018 Lab 9 for the Week of March 19

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

Computer Architecture I Midterm I

COMP2611: Computer Organization MIPS function and recursion

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

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

Lecture 5: Procedure Calls

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

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

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

Lecture 6: Assembly Programs

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

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

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

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

ENCM 369 Winter 2015 Lab 6 for the Week of March 2

Midterm. CS64 Spring Midterm Exam

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

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

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

CS/COE1541: Introduction to Computer Architecture

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

CSCI 2321 (Computer Design), Spring 2018 Homework 3

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

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

CS222: MIPS Instruction Set

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

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

CS222: Dr. A. Sahu. Indian Institute of Technology Guwahati

CS 61C: Great Ideas in Computer Architecture (Machine Structures) More MIPS Machine Language

CS3350B Computer Architecture

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

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

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

ECE 2035 A Programming Hw/Sw Systems Spring problems, 8 pages Final Exam 29 April 2015

SPIM Procedure Calls

Computer Organization MIPS ISA

Computer Organization and Components

CSE Lecture In Class Example Handout

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

University of Calgary Department of Electrical and Computer Engineering ENCM 339: Programming Fundamentals, Section 01 Instructor: Steve Norman

ECE 473 Computer Architecture and Organization Project: Design of a Five Stage Pipelined MIPS-like Processor Project Team TWO Objectives

CS64 Week 5 Lecture 1. Kyle Dewey

bits 5..0 the sub-function of opcode 0, 32 for the add instruction

Procedure Call and Return Procedure call

MIPS Functions and Instruction Formats

Lab 4 : MIPS Function Calls

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

CSc 256 Midterm (green) Fall 2018

I-Format Instructions (3/4) Define fields of the following number of bits each: = 32 bits

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

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

CS 61c: Great Ideas in Computer Architecture

CS61C : Machine Structures

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 8 December 2014

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

ECE 15B COMPUTER ORGANIZATION

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

(a) Implement processor with the following instructions: addi, sw, lw, add, sub, and, andi, or, ori, nor, sll, srl, mul

CS61c MIDTERM EXAM: 3/17/99

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

CPSC 330 Computer Organization

MIPS%Assembly% E155%

CSE 141 Computer Architecture Spring Lecture 3 Instruction Set Architecute. Course Schedule. Announcements

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

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

Lecture 7: Examples, MARS, Arithmetic

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

Machine Organization & Assembly Language

ECE 2035 A Programming Hw/Sw Systems Spring problems, 8 pages Final Exam Solutions 29 April 2015

Procedure Calling. Procedure Calling. Register Usage. 25 September CSE2021 Computer Organization

Transcription:

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, February 8 7:00pm to 8:30pm Please do not write your U of C ID number on this cover page. Name (printed): Signature: Lecture section (01 is MWF 11:00am with S. Norman, 02 is MWF 10:00am with N. Bartley): General Instructions Marks will be recorded on the last page of this question paper. When you are told to start the test, the first thing you should do is to put your name, signature, U of C ID number, and lecture section in the appropriate spaces at the bottom of the last page. If you use a calculator, it must be one of the following models sanctioned by the Schulich School of Engineering: Casio FX-260, Casio FX-300MS, TI- 30XIIS. The test is closed-book. You may not refer to books or notes during the test, with one exception: you may refer to the Reference Material page that accompanies this test paper. You are not required to add comments to assembly language code you write, but you are strongly encouraged to do so, because writing good comments will improve the probability that your code is correct and will help you to check your code after it is finished. Some problems are relatively easy and some are relatively difficult. Go after the easy marks first. To reduce distraction to other students, you are not allowed to leave during the last ten minutes of the test. Write all answers on the question paper and hand in the question paper when you are done. Please print or write your answers legibly. What cannot be read cannot be marked. If you write anything you do not want marked, put a large X through it and write rough work beside it. You may use the backs of pages for rough work.

ENCM 369 Winter 2017: Midterm Test #1 page 2 of 5 PROBLEM 1 (11 marks) Consider the listed to the right. Translate the function foo into MARS assembly language. Follow the usual calling conventions from lectures and labs, and use only instructions from the Midterm Instruction Subset described on the Reference Material page. int bar(int x); int quux(int y); int foo(const int *a, int *b, int n) int j, k, aj; k = 0; for (j = 0; j < n; j++) aj = a[j]; if(bar(aj)!= 0) b[k] = quux(aj); k++; return k;

ENCM 369 Winter 2017: Midterm Test #1 page 3 of 5 PROBLEM 2 (total of 13 marks). In this problem, you are asked to translate sequences of one or more C statements into sequences of one or more MARS instructions, not complete MARS procedures. Use only instructions from the Midterm Instruction Subset. Use as many t-registers as you wish for intermediate values. Example. (No marks.) $s0 is used for x, of type int. x = 42; addi $s0, $zero, 42 Part a. (3 marks.) $s2 is used for p, of type int*. $s3 is used for q, also of type int*. *p = *q - 3; q = p - 2; Part b. (3 marks.) a is an array of char elements on the stack, and the address of a[0] is 20($sp). $s5 is used for p, of type char*. p = a; while (*p!= \0 ) p++; Part c. (4 marks.) j, in $s3, and k, in $s4, are both of type int. f takes an argument of type int and returns a value of type int. if (j < 10 f(j) < 100) k++; else k--; Part d. (3 marks.) y, in $s1, and x, in $s2, are both of type int. (Hint: 20 = 16 + 4.) y = 20 * x;

ENCM 369 Winter 2017: Midterm Test #1 page 4 of 5 PROBLEM 3 (13 marks). The MARS assembly-language program on this page is a correct translation of the C program. Fill in the table of GPRs and the blank boxes in the diagram of memory with numbers to show the state of the assembly-language program, at the third of the four times it will get to point one. label zed wye main exx address 0x0040_0030 0x0040_0044 0x0040_00b0 0x1001_0000 GPR value of GPR when main starts $s0 111 $s1 222 $s2 333 $sp 0x7fff_eb80 $ra 0x0040_0028 Use base ten or hexadecimal format for numbers, whichever is more convenient for any particular number. Note that some of the memory words in the diagram might not be used by the program. GPR values, third time at point one GPR $a0 $v0 $s0 $s1 $s2 $t3 $sp value Memory, third time at point one higher addresses STACK data saved before main was called..data int zed(int za) return za >= -8 && za < 9; void wye(int *a, int *aend, const int *b) while (a < aend) if (zed(*b)) *a = *b; else *a = 12; a++; b++; int exx[4] = -9, -8, 11, 8 ; int main(void) int ww[4]; wye(ww, ww + 4, exx); //...more code... zed:.globl zed addi $v0, $zero, 0 slti $t0, $a0, -8 bne $t0, $zero, L1 slti $v0, $a0, 9 # POINT ONE L1: jr $ra.globl wye wye: addi $sp, $sp, -16 sw $ra, 12($sp) sw $s2, 8($sp) sw $s1, 4($sp) sw $s0, 0($sp) add $s0, $a0, $zero add $s1, $a1, $zero add $s2, $a2, $zero L2: slt $t2, $s0, $s1 beq $t2, $zero, L3 lw $a0, ($s2) jal zed beq $v0, $zero, L4 lw $t3, ($s2) sw $t3, ($s0) j L5 L4: addi $t4, $zero, 12 sw $t4, ($s0) L5: addi $s0, $s0, 4 addi $s2, $s2, 4 j L2 L3: lw $s0, 0($sp) lw $s1, 4($sp) lw $s2, 8($sp) lw $ra, 12($sp) addi $sp, $sp, 16 jr $ra.data.globl exx exx:.word -9, -8, 11, 8.globl main main: addi $sp, $sp, -20 sw $ra, 16($sp) addi $a0, $sp, 0 addi $a1, $sp, 16 la $a2, exx jal wye #... more code... addi $v0, $zero, 0 lw $ra, 16($sp) addi $sp, $sp, 16 jr $ra 0x1001_0000 return 0;

ENCM 369 Winter 2017: Midterm Test #1 page 5 of 5 PROBLEM 4 (total of 7 marks) Part a. (4 marks.) Assume that $t0 contains 0x0003_5000 and $t1 contains 0x000a_6000 before the following sequence of instructions runs: and $t2, $t0, $t1 nor $t3, $t1, $zero srl $t4, $t2, 2 lui $t5, 0x73ac What are the values in $t2, $t3, $t4, and $t5 after the instructions have run? Give your answers as hexadecimal numbers. Part b. (3 marks.) In ENCM 369, the words preprocessor and compiler are the names for two tools in the toolchain for building executable files from C source files. Briefly but precisely describe what each of these two tools does. MARKS: The space below will be used to record your marks for each question and your overall test mark. Please put your name, signature, and U of C ID number in the appropriate boxes. Name (printed): Signature: U of Calgary ID number: Problem Mark 1 / 11 2 / 13 3 / 13 4 / 7 Lecture Section (01 is 11:00am with S. Norman, 02 is 10:00am with N. Bartley): TOTAL / 44