Docsity

Practice Exam Two - Fall 2007 - Mechanisms-Computing Systems | ECE 3035, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE 3035 A Computing Mechanisms Fall 2007
4 problems, 7 pages Exam Two 7 November 2007
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
A
B
C total
D
30 23 28 19 100
pf3
pf4
pf5

Partial preview of the text

Download Practice Exam Two - Fall 2007 - Mechanisms-Computing Systems | ECE 3035 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

4 problems, 7 pages Exam Two 7 November 2007

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

A

B

C total

D 30 23 28 19 100

4 problems, 7 pages Exam Two 7 November 2007

Problem 1 (1 part, 30 points) Activation Frames

Part A (20 points) The function Bar (below left) calls function Foo after completing code block 1. Write MIPS assembly code that properly calls^ Foo. Include all instructions between code block 1 and code block 2. Symbolically label all required stack entries and give their values if they are known (below right).

int Bar() { int V[] = {9, 4, 1}; int R = V[2];

(code block 1)

R = Foo(R, &R, V)

(code block 2) }

label instruction comment

Bar’s FP 9900 XXX XXX 9896 V[2] 1 9892 V[1] 4 9888 V[0] 9 SP 9884 R 1 9880

9876

9872

9868

9864

9860

9856

4 problems, 7 pages Exam Two 7 November 2007

Problem 2 (1 part, 23 points) Hash Tables and Heap Consider an open hash table composed of a four-bucket table, with each bucket containing a variable length list. Each list entry has three slots corresponding to the three word groupings in the entries section. The hash function is key mod four. Inserted entries are appended to the end of a bucket list. Deallocated entries are maintained on a LIFO free list. When the free list is empty, new entry objects are allocated from heap memory. Accesses are listed as . Simulate the access list below and draw the ending state. Assume the hash table is initially empty, the heap pointer is initially 5016 and the free pointer is initially

Heap Pointer

(^5016) Free List

Buckets

5000 5004 5008 5012

Entries

5016 5040 5066 5090

Hash Table Access Trace

op key value # op key value

1 insert 1006 111 5 insert 1002 555 2 insert 1000 222 6 remove 1000 n/a 3 insert 1004 333 7 remove 1002 n/a 4 insert 1006 444 8 insert 1003 666

4 problems, 7 pages Exam Two 7 November 2007

Problem 3 (4 parts, 28 points) Baseline Implementation

Consider the following fragment from the HeapManager baseline implementation. Recall that $ is the freed object pointer and $3 is the free list. beq $3, $0, Label1 # I add $6, $3, $0 # I lw $4, -4($2) # I lw $5, -4($3) # I slt $5, $5, $4 # I bne $5, $0, Label3 # I Label1: sw $3, 0($2) # I Part A (6 points) Using terms defined in the project, define what is being compared in I05(slt). Don't simply transliterate the MIPS instructions (e.g., don't say “reg 2 is added to reg 3”).

Part B (6 points) Describe the two cases where I07(sw) is executed in terms defined in the project specification. Be specific.

char *Heap = 5000; void *Object = 6000; void **Free = 7000;

mem[5000] = 5500 mem[6000] = 6500 mem[7000] = 7500

Part C (12 points) Consider the three pointers above. Assume their initialized value is the address of an appropriate address in memory. For each statement below, list the resultant value. If the value is undecidable, state “error”.

Heap + 1 Object + 1 Free + 1 ((int *) *Free) + 1

Part D (4 points) Concisely define the following terms?

void pointer:

null pointer:

4 problems, 7 pages Exam Two 7 November 2007

MIPS Instruction Set (core) instruction example meaning arithmetic add add $1,$2,$3 $1 = $2 + $ subtract sub $1,$2,$3 $1 = $2 - $ add immediate addi $1,$2,100 $1 = $2 + 100 add unsigned addu $1,$2,$3 $1 = $2 + $ subtract unsigned subu $1,$2,$3 $1 = $2 - $ add immediate unsigned addiu $1,$2,100 $1 = $2 + 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 $ 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 & $ or or $1,$2,$3 $1 = $2 | $ and immediate andi $1,$2,100 $1 = $2 & 100 or immediate ori $1,$2,100 $1 = $2 | 100 nor nor $1,$2,$3 $1 = not($2 | $3) xor xor $1, $2, $3 $1 = $2 ⊕ $ 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] = $ 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 + (1004) branch if not equal bne $1,$2,100 if ($1 ≠ $2), PC = PC + 4 + (1004) jump jump j 10000 PC = 10000* jump register jr $31 PC = $ jump and link jal 10000 $31 = PC + 4; PC = 10000*