Write code to properly set Foo s frame pointer label instruction Comment add 30

# Write code to properly set foo s frame pointer label

This preview shows page 3 - 5 out of 5 pages.

You may not need as many lines as are provided. Write code to properly set Foo ’s frame pointer. label instruction Comment add \$30, \$29, \$0 # set Foo's FP *Y = *Y >> 2; label instruction Comment lw \$1, 4(\$30) # load Y pointer lw \$2, 0(\$1) # dereference Y (20) sra \$2, \$2, 2 # 20/4 = 5 sw \$2, 0(\$1) # store in loc pt'd to by Y Y++; label instruction Comment lw \$1, 4(\$30) # [load Y pointer] addi \$1, \$1, 4 # increment Y (by 4 bytes) sw \$1, 4(\$30) # update Y X[1] = *Y; label instruction Comment lw \$2, 0(\$1) # dereference Y (9) lw \$1, 8(\$30) # load base address of X sw \$2, 4(\$1) # store 9 at X[1] return (X[1]*16); label instruction Comment sll \$1, \$1, 4 # compute X[1]*16 sw \$1, 0(\$30) # store result in RV slot jr \$31 # return to caller 3
ECE 3035 Computing Mechanisms Fall 2010 4 problems, 7 pages Exam Two Solutions 27 October 2010 Problem 3 (2 parts, 16 points) Parameter Passing Part A (12 points) Consider the following C code fragment. struct Point { float X, Y, Z; } Point Foo() { float A, *B, C[5]; struct Point D, E[4]; ... Bar(A, B, C, D, E); ... } In the code above, a function Foo calls another function Bar . Five variables are passed to the called function. Complete the table below indicating whether the intent of each passed parameter is call by value or call by reference. Circle the appropriate label. Also list the number of bytes required in the activation frame for each parameter and Foo's return value. Assume a 32 bit ISA. parameter call by size in activation frame (in bytes) A value reference 4 B value reference 4 C value reference 4 D value reference 12 E value reference 4 Foo's RV 12 Part B (4 points) List the four things typically found in a header file. 1: cpp macros (#define definitions) 2: struct and typedef definitions 3: extern data and function declarations (prototypes) 4: include files 4
ECE 3035 Computing Mechanisms Fall 2010 4 problems, 7 pages Exam Two Solutions 27 October 2010 Problem 4 (5 parts, 22 points) Vision Utilities Project One includes a jpeg image utility that includes two new struct types suited for the task.

#### You've reached the end of your free preview.

Want to read all 5 pages?

• Fall '08
• Staff
• activation frame, frame buffer

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern