573exam2

# 573exam2 - ECE 573 — Midterm 2 November 3 2009 Name...

This preview shows pages 1–5. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ECE 573 — Midterm 2 November 3, 2009 Name: ______________________________________ Purdue email: ______________________________________ Please sign the following: I afFrm that the answers given on this test are mine and mine alone. I did not receive help from any person or material (other than those explicitly allowed). X ___________________________________________ Part Points Score 1 20 2 12 3 40 4 38 5 30 Total 140 Part 1: Semantic actions and functions (20 pts) 1) Why is it useful to pass arguments as read-only? (2 pts) 2) Draw the AST that would be generated for the expression *(p) + x and for each AST node, show the data object that would be generated. For each data object, show the code that would be generated (if any), the temporary the result will be stored in, and whether the temporary is an R-value or an L-value. (8 pts) 3) Here is a partial stack of a method being executed (the stack grows down). Show the stack after calling int foo(int a, int b) . Show the frame pointer, and note how much space each part of the stack occupies (32-bit ints and pointers). Assume that we are using a callee-saves convention, and that the machine has 4 registers (plus FP & SP registers). Assume that there are no nested scopes or local variables in foo. (10 pts) Rest of stack Local variables Part 2: Common subexpression elimination (12 pts) For the next questions, consider the following piece of code: 1: A = B + C; 2: D = A - C; 3: E = B + C; 4: B = C + E; 5: F = A - C; 6: G = B + C; 1) Assume there is no aliasing between variables. For each statement, list which 1) Assume there is no aliasing between variables....
View Full Document

{[ snackBarMessage ]}

### Page1 / 12

573exam2 - ECE 573 — Midterm 2 November 3 2009 Name...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online