Docsity

Computing Mechanisms Exam - Fall 2004, Exams of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE 3035B Computing Mechanisms Fall 2004
5 problems, 8 pages Final Exam 7 December 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. For
maximum credit, show your work.
Good Luck!
Your Name (please print) ________________________________________________
1 2 3 4 5 total
20 20 25 15 20 100
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Computing Mechanisms Exam - Fall 2004 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

5 problems, 8 pages Final Exam 7 December 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. For

maximum credit, show your work.

Good Luck!

Your Name ( please print ) ________________________________________________

1 2 3 4 5 total

5 problems, 8 pages Final Exam 7 December 2004

Problem 1 (3 parts, 20 points) Virtual Memory

Answer the following questions for a byte-addressed virtual memory system that uses the

following virtual and physical address formats.

Virtual Address

page number page offset total VA length

28 + 12 = 40

Physical Address

frame number page offset total PA length

20 + 12 = 32

Part A (10 points) Determine the following values:

page size bytes

size of virtual address space (byte addressed) bytes

size of physical memory (used for frames) bytes

number of pages pages

number of frames frames

Part B (8 points) Assume the following translations are available in the page table (all values are

in hexadecimal). For each virtual address listed below, determine the corresponding physical

address (if available). Indicate which VAs will result in a page fault given this table.

page number frame number disk location

CAB1234 F6C3 2364514

DE826 111 2836452

35C D3A4B 7665358

DE829 N/A 2754830

DE820 325 3476268

virtual address physical address page fault?

DE8269AC

DE

DE

35CF

Part C (2 points) What virtual address would translate to the physical address F6C3358 using

the page table in part B?

Virtual Address:

5 problems, 8 pages Final Exam 7 December 2004

Problem 3 (5 parts, 25 points) Call/Return using Activation Frames

Consider the following function:

int Test(int a) { int x = 33; int y; y = a + x; x = Solve(a, x, y) return x; }

This problem involves writing the MIPS code to implement Test in parts. The beginning of Test’s

activation frame is shown on the stack. This is the state of the stack as Test is called:

HI

FP -> Caller’s return value Caller’s locals

Caller of Test’s AF ends here RA of caller FP of caller a SP -> Return value

Test’s AF starts here

LO

Part A (6 points) Write MIPS code to complete Test’s activation frame by pushing locals on the stack.

Be sure to update the frame pointer properly.

Test:

Part B (4 points) Compute the “y = a + x;” statement by accessing “a” and “x” from the stack. Be

sure to update locals in the current stack activation frame.

5 problems, 8 pages Final Exam 7 December 2004

Part C (6 points) Fill in the MIPS code necessary before the call to Solve. You will need to prepare the

stack and preserve registers that will be needed after the function call.

jal Solve # call Solve

Part D (5 points) Fill in the MIPS code after the call to Solve to restore the values from Solve’s

activation frame and assign the value of “x”.

Part E (4 points) Finish the implementation of Test by implementing its return to its caller.

5 problems, 8 pages Final Exam 7 December 2004

Problem 5 (3 parts, 20 points) DarkMaze Implementation

Use the following code fragment from the DarkMaze baseline to answer the following parts.

Address Label Instruction

1000 swi^505 1004 beq $3, $0, L 1008 beq $3, $7, L 1012 jal Search 1016 L1: addi $2, $2, - 1020 andi^ $2, $2, 3 1024 swi 505 1028 beq $3, $0, L 1032 beq $3, $7, L 1036 jal Search 1040 L2: addi $2, $2, 2 1044 andi $2, $2, 3 1048 swi 505 1052 beq $3, $0, L 1056 beq $3, $7, L 1060 jal Search 1064 L3: addi $2, $2, - 1068 addi $2, $2, 2 1072 andi $2, $2, 3 1076 swi 505 1080 addi $2, $2, 2 1084 andi $2, $2, 3 1088 L4:

Part A (5 points) Partition the MIPS code into basic blocks. For each basic block, fill in a box to the

right with the address range of the instructions in the basic block. For example, if instructions at

addresses 2000 through 2004 form a basic block, write “2000-2004” in a box. As a simplification, for

this problem, treat the swi and jal instructions as straightline instructions that do not transfer control.

Fill in one box for each basic block. You may not need to use all of the boxes. Boxes B1 and B14 have

already been filled in as examples.

Part B (7 points) On the next page , draw the control flow graph of the MIPS code, using the boxes you

filled in for Part A. Label the edges of the control flow graph with “T” and “F” where appropriate. You

do not need to fill in the boxes with addresses or instructions. The boxes B1 and B14 have already been

placed on the next page to get you started.

Part C (8 points) Describe the sequence of direction ($2) changes in the shaded instructions of this

fragment (i.e., what change has occurred to $2 by the end of each andi instruction). Describe what each

change is relative to the initial direction (e.g., forward, reverse, left, or right).

st

change 2

nd

change: 3

rd

change 4

th

change

B1:

B2:

B5:

B6:

B9:

B10:

B8:

B14:

B3:

B4:

B7:

B12:

B13:

B11:

5 problems, 8 pages Final Exam 7 December 2004

Part B: Control Flow Graph

B

B