ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed.

Similar documents
ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)

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

Q1: /30 Q2: /25 Q3: /45. Total: /100

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

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

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

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

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

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

ECE 2035 A Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 14 December 2016

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Three 10 April 2013

ECE 2035 Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 9 December 2013

F. Appendix 6 MIPS Instruction Reference

MIPS Instruction Reference

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck!

Assembly Programming

Week 10: Assembly Programming

MIPS Reference Guide

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

TSK3000A - Generic Instructions

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

The MIPS Instruction Set Architecture

Reduced Instruction Set Computer (RISC)

Arithmetic for Computers

Computer Architecture. The Language of the Machine

Computer Architecture. MIPS Instruction Set Architecture

Reduced Instruction Set Computer (RISC)

MIPS Instruction Format

SPIM Instruction Set

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support

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

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

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

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

Examples of branch instructions

CS 61c: Great Ideas in Computer Architecture

MIPS Instruction Set

ECE 15B Computer Organization Spring 2010

Number Systems and Their Representations

Instruction Set Architecture of. MIPS Processor. MIPS Processor. MIPS Registers (continued) MIPS Registers

Mips Code Examples Peter Rounce

CSc 256 Midterm (green) Fall 2018

Programming the processor

CSc 256 Midterm 2 Spring 2012

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA

CPS311 - COMPUTER ORGANIZATION. A bit of history

MACHINE LANGUAGE. To work with the machine, we need a translator.

M2 Instruction Set Architecture

CSc 256 Midterm 2 Fall 2011

Flow of Control -- Conditional branch instructions

Review. Lecture #9 MIPS Logical & Shift Ops, and Instruction Representation I Logical Operators (1/3) Bitwise Operations

Computer Architecture Experiment

MIPS Assembly Language. Today s Lecture

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

Midterm. Sticker winners: if you got >= 50 / 67

MIPS%Assembly% E155%

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

CSc 256 Final Fall 2016

Midterm. CS64 Spring Midterm Exam

UCB CS61C : Machine Structures

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers

Recap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011

Part II Instruction-Set Architecture. Jan Computer Architecture, Instruction-Set Architecture Slide 1

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

EE 109 Unit 13 MIPS Instruction Set. Instruction Set Architecture (ISA) Components of an ISA INSTRUCTION SET OVERVIEW

CS61c MIDTERM EXAM: 3/17/99

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

INSTRUCTION SET COMPARISONS

Review: MIPS Organization

CMPE324 Computer Architecture Lecture 2

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

Concocting an Instruction Set

Computer Organization & Design

A General-Purpose Computer The von Neumann Model. Concocting an Instruction Set. Meaning of an Instruction. Anatomy of an Instruction

CS3350B Computer Architecture MIPS Instruction Representation

Project Part A: Single Cycle Processor

CPE 335 Computer Organization. MIPS Arithmetic Part I. Content from Chapter 3 and Appendix B

CS 61c: Great Ideas in Computer Architecture

Exam in Computer Engineering

UCB CS61C : Machine Structures

CS61C : Machine Structures

UCB CS61C : Machine Structures

Digital System Design II

EE 109 Unit 8 MIPS Instruction Set

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

CS61C : Machine Structures

The MIPS R2000 Instruction Set

CS61C Machine Structures. Lecture 10 - MIPS Branch Instructions II. 2/8/2006 John Wawrzynek. (

Mark Redekopp, All rights reserved. EE 352 Unit 3 MIPS ISA

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

Review of instruction set architectures

software hardware Which is easier to change/design???

MIPS Assembly Language

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

Concocting an Instruction Set

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

ece4750-parc-isa.txt

Transcription:

Your Name (please print clearly) This exam will be conducted according to the Georgia Tech Honor Code. I pledge to neither give nor receive unauthorized assistance on this exam and to abide by all provisions of the Honor Code. Signed 1 2 3 total 30 35 35 100 Instructions: This is a closed book, closed note exam. Calculators are not permitted. Read each question over before you start to work. If you have a question, raise your hand; do not leave your seat. The meaning of each question should be clear, but if something does not make any sense to you, please ask for clarification. Please work the exam in pencil and do not separate the pages of the exam. If you run out of room, please continue on the back of the previous page. For maximum credit, show your work. Good Luck! 1

Problem 1 (4 parts, 30 points) Loops Consider the following C code fragment: int H[100] = 1997, 2, -7, 1, 2010, 4, 3, 6,, 17; int i, x, y, z; for (i = 1; i<100; i = i+4) x = H[i]; y = H[i+1]; <code block A> z = i; The body of this fragment contains <code block A> to indicate additional instructions not shown. This block uses i, but does not change the value of i. It also does not contain continue or break statements. Part A (4 points) How many times is <code block A> executed? Answer:. Part B (4 points) What is the minimum value of i? Answer:. Part C (4 points) What is the final value of z? Answer:. Part D (18 points) Write a MIPS code fragment that is equivalent to the C code above. Use the following register assignments: $1: i, $2: x, $3: y, $4:z. Use additional registers if necessary. Use <code block A> in your MIPS code to indicate where the instructions for this code block go. For maximum credit, include comments. (Note: there are more blank lines provided than you need.) Label Instruction Comment.data H:.word 1997, 2, -7, 1, 2010,, 17 # int H[100]=1997, 2,, 17;.text 2

Problem 2 (2 parts, 35 points) Conditionals: Compound Predicates Consider the following C code fragment, where the variables Hs, He, Ss, and Se are integers: if ((Se >= Hs) && (He >= Ss)) <code block A> else <code block B> <code block C> Part A (15 points) Write the equivalent C fragment using a logical or ( ) instead of logical and (&&). Hint: Use DeMorgan's Theorem and swap the then and else clauses. It may be helpful to draw the control flow graph. Part B (20 points) Turn the C code fragment into the equivalent MIPS code. The variables are held in these registers: $1: Hs, $2: He, $3: Ss and $4: Se. Use additional registers if necessary. Use <code block A/B/C> to indicate where the instructions for these code blocks go. For maximum credit, include comments and use a minimal number of instructions. (More blank lines are provided than you need.) Label Instruction Comment 3

Problem 3 (4 parts, 35 points) Understanding Code Part A (9 points) What values are in registers $1 and $2 after this MIPS code fragment executes? Express your answers in hexadecimal. # $1: 0x # $2: 0x lui $1, 0x1 addi $2, $1, 0xABCD Part B (9 points) Given the following MIPS code:.data Input:.word 0xAABBCCDD.text addi $3, $0, Input Write a single MIPS instruction that is equivalent to the original MIPS fragment. Assume little endian byte ordering. Original: addi $4, $0, 8 lw $5, 0($3) srlv $5, $5, $4 andi $5, $5, 0xFF Equivalent MIPS instruction: Part C (8 points) What are the values of the variables x, y, z, and w after the following C code fragment executes? Express your answers in decimal. Hint: remember how C implements compound predicates. int x, y, z; x = y = z = 33; int w = 10; if ((x == 44) (y = 5) (z = 8)) // note == vs = w = 77; Variable: Value: x y z w 4

Part D (9 points) What does the following code fragment print? int V[] = 1, 5, 7, 6, -9, 17, -20, 0, -3; int j, i=0; while(v[i]!= 0) printf( V[%d]: %d\n, i,v[i]); if (V[i] < 0) for (j=0; j<i; j++) if (j == 2) continue; printf( j: %d\n, j); break; i++; 5

MIPS Instruction Set (core) instruction example meaning arithmetic add add $1,$2,$3 $1 = $2 + $3 subtract sub $1,$2,$3 $1 = $2 - $3 add immediate addi $1,$2,100 $1 = $2 + sign_extend(100) add unsigned addu $1,$2,$3 $1 = $2 + $3 subtract unsigned subu $1,$2,$3 $1 = $2 - $3 add immediate unsigned addiu $1,$2,100 $1 = $2 + zero_extend(100) set if less than slt $1, $2, $3 if ($2 < $3), $1 = 1 else $1 = 0 set if less than immediate slti $1, $2, 100 if ($2 < 100), $1 = 1 else $1 = 0 set if less than unsigned sltu $1, $2, $3 if ($2 < $3), $1 = 1 else $1 = 0 set if < immediate unsigned sltui $1, $2, 100 if ($2 < 100), $1 = 1 else $1 = 0 multiply mult $2,$3 Hi, Lo = $2 * $3, 64-bit signed product multiply unsigned multu $2,$3 Hi, Lo = $2 * $3, 64-bit unsigned product divide div $2,$3 Lo = $2 / $3, Hi = $2 mod $3 divide unsigned divu $2,$3 Lo = $2 / $3, Hi = $2 mod $3, unsigned transfer move from Hi mfhi $1 $1 = Hi move from Lo mflo $1 $1 = Lo load upper immediate lui $1,100 $1 = 100 x 2 16 logic and and $1,$2,$3 $1 = $2 & $3 or or $1,$2,$3 $1 = $2 $3 and immediate andi $1,$2,100 $1 = $2 & zero_extend(100) or immediate ori $1,$2,100 $1 = $2 zero_extend(100) nor nor $1,$2,$3 $1 = not($2 $3) xor xor $1, $2, $3 $1 = $2 $3 xor immediate xori $1, $2, 255 $1 = $2 255 shift shift left logical sll $1,$2,5 $1 = $2 << 5 (logical) shift left logical variable sllv $1,$2,$3 $1 = $2 << $3 (logical), variable shift amt shift right logical srl $1,$2,5 $1 = $2 >> 5 (logical) shift right logical variable srlv $1,$2,$3 $1 = $2 >> $3 (logical), variable shift amt shift right arithmetic sra $1,$2,5 $1 = $2 >> 5 (arithmetic) shift right arithmetic variable srav $1,$2,$3 $1 = $2 >> $3 (arithmetic), variable shift amt memory load word lw $1, 1000($2) $1 = memory [$2+1000] store word sw $1, 1000($2) memory [$2+1000] = $1 load byte lb $1, 1002($2) $1 = memory[$2+1002] in least sig. byte load byte unsigned lbu $1, 1002($2) $1 = memory[$2+1002] in least sig. byte store byte sb $1, 1002($2) memory[$2+1002] = $1 (byte modified only) branch branch if equal beq $1,$2,100 if ($1 = $2), PC = PC + 4 + (100*4) branch if not equal bne $1,$2,100 if ($1 $2), PC = PC + 4 + (100*4) jump jump j 10000 PC = 10000*4 jump register jr $31 PC = $31 jump and link jal 10000 $31 = PC + 4; PC = 10000*4 6