Docsity

Practice Exam 1 - Mechanisms-Computing System | ECE 3035, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE 3035 A 10:00am Computing Mechanisms Fall 2004
4 problems, 5 pages Exam One 15 September 2004
1
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 the pages of the exam. For maximum credit, show your work.
Good Luck!
Your Name (please print) ________________________________________________
1 2 3 4 total
30 25 30 15 100
pf3
pf4
pf5

Partial preview of the text

Download Practice Exam 1 - Mechanisms-Computing System | ECE 3035 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

4 problems, 5 pages Exam One 15 September 2004

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 the pages of the exam. For maximum credit, show your work. Good Luck!

Your Name ( please print ) ________________________________________________

1 2 3 4 total

4 problems, 5 pages Exam One 15 September 2004

Problem 1 (2 parts, 30 points) ColorMatch Implementation

Part A (10 points) In the ColorMatch program, three unsigned integers are packed in a single 32 bit word. Suppose the unsigned integers are each ten bits (see below) rather than eight bits. Write MIPS code that unpacks the three components from an input value already loaded into register $5, and stores the R, G, and B in $5, $6, and $7 respectively. Only $5, $6, and $7 should be modified in your fragment. All numbers should be expressed in decimal.

31 0

unused red component green component blue component

31 30 29 20 19 10 9 0

label instruction comment

Part B (20 points) In the ColorMatch program, all pairings of eight colors are compared. In this simplified exercise, write the MIPS looping structure that generates all unique pairing of the integers 0-99. Pairs should be considered once and a number should not be compared to itself. The order of comparison is irrelevant so two numbers should be compare in only one order. The two numbers should be created in $1 and $2. Place the phrase “compare code” in the instruction field where the body of the comparison instructions would be inserted. $3 can be used as a predicate register. Hint: to save instructions, loop down to zero.

label instruction comment

4 problems, 5 pages Exam One 15 September 2004

Problem 3 (3 parts, 30 points) Stacks

Consider the recursive factorial program below. Suppose it is called with an input value of 5 using the jal at memory address 2000. $29 = 9100 immediately before Fact is called at 2000. Answer the following questions below about the state of the machine immediately following completion of the recursive factorial execution when “next instruction” begins.

1000 Fact: addi $02, $00, 1 1004 slti $03, $01, 2 1008 bne $03, $00, Skip 1012 addi $29, $29, - 1016 sw $31, 4($29) 1020 sw $01, 0($29) 1024 addi $01, $01, - 1028 jal Fact 1032 lw $01, 0($29) 1036 lw $31, 4($29) 1040 addi $29, $29, 8 1044 mult $01, $ 1048 mflo $ 1052 Skip: jr $

2000 jal Fact 2004 next instruction

Part A (10 points) What are the contents of the following registers:

$1: $2: $3: $29: $31:

Part B (10 Points) What is the contents of the stack when the instruction at 2004 begins?

4 problems, 5 pages Exam One 15 September 2004

Part C (10 Points) When Fact is called with input = 5, how many instructions are executed. Do not count the jal at 2000 or the “next instruction”. Show work.

Number of instruction executed (dynamic I) =

Problem 4 (1 part, 15 points) C Code

Write a C program, Max(), that returns the maximum value of the following global array.

int Array[25] = {23, -54, 31, …};